Update flake with direnv; add bashInteractive; fix creating new entries for the new year
This commit is contained in:
@@ -122,7 +122,14 @@ class DatabaseAPI extends ChangeNotifier {
|
||||
limit: 1,
|
||||
paginationQuery: Query.offset(offset),
|
||||
);
|
||||
_entries.add(response.first);
|
||||
if(response.isEmpty){
|
||||
print("No entry in database; creating $date");
|
||||
Document newEntry = await addEntry(date: date);
|
||||
_entries.add(newEntry);
|
||||
}
|
||||
else{
|
||||
_entries.add(response.first);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -185,14 +192,15 @@ class DatabaseAPI extends ChangeNotifier {
|
||||
Future<Document> addEntry(
|
||||
{required String date,
|
||||
List hours = const [],
|
||||
int mood = -1,
|
||||
String comments = ""}) {
|
||||
dynamic mood,
|
||||
String comments = ""}) async {
|
||||
|
||||
return databases.createDocument(
|
||||
databaseId: APPWRITE_DATABASE_ID,
|
||||
collectionId: COLLECTION,
|
||||
documentId: date,
|
||||
data: {
|
||||
'date': DateTime.parse(date),
|
||||
'date': date,
|
||||
'hours': hours,
|
||||
'mood': mood,
|
||||
'comments': comments
|
||||
|
||||
Reference in New Issue
Block a user