Update flake with direnv; add bashInteractive; fix creating new entries for the new year

This commit is contained in:
2024-01-01 16:23:37 -05:00
parent e01bd9895e
commit fd171b8aa7
3 changed files with 18 additions and 8 deletions
+12 -4
View File
@@ -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