Fix invalid categories finally!

This commit is contained in:
2024-01-19 01:44:25 -08:00
parent fd171b8aa7
commit ececb7439a
7 changed files with 57 additions and 15 deletions
@@ -47,29 +47,34 @@ class _DayViewState extends State<DayView> {
}
}
@override
Widget build(BuildContext context) {
void getDayEntry() async{
List<Document> entries = database.entries;
String formattedDate = formatDate(
dateISO: _date.toIso8601String(),
format: "yyyy-MM-dd",
);
try {
dayEntry = entries.singleWhere((element) => element.$id == formattedDate);
String date = formatDate(
format: "LLL d", dateISO: dayEntry?.data['date'].toString());
print("Got entry for $date");
} catch (e) {
database.getOne(date: formattedDate).then((value) {
dayEntry = value;
});
dayEntry = entries.last;
print("Got entry for ${entries.last.$id}");
}
// print(entries.length);
}
@override
Widget build(BuildContext context) {
getDayEntry();
setState(() {
if (dayEntry != null) {
comments = dayEntry?.data["comments"];
String? newComment = dayEntry?.data["comments"];
if(newComment == null){
newComment = "";
}
comments = newComment;
mood = dayEntry?.data["mood"];
}
});
@@ -512,7 +517,7 @@ class _HourFormFieldState extends State<HourFormField> {
}
});
if (widget.category != null) {
catNum = widget.category!.number.toString();
catNum = widget.dayEntry!.data['hours'][widget.index].toString();
fgColor = widget.category!.foregroundColor;
catName = widget.category!.name;
}