Oops, forgot to store the entries that were scanned. They just disappeared after restarting the app

This commit is contained in:
Marco 2024-10-02 16:22:33 +02:00
parent 37cceb3a9b
commit 970cea8ba7

View File

@ -84,7 +84,7 @@ class FoodEntryBloc extends Bloc<FoodEvent, PageState> {
newList.add(newEntryWaiting); newList.add(newEntryWaiting);
emit(PageState(foodEntries: newList)); emit(PageState(foodEntries: newList));
await responseFuture.then((response) { await responseFuture.then((response) async {
var index = newList var index = newList
.indexWhere((entryState) => entryState.id == newEntryWaiting.id); .indexWhere((entryState) => entryState.id == newEntryWaiting.id);
@ -117,6 +117,10 @@ class FoodEntryBloc extends Bloc<FoodEvent, PageState> {
newList.removeAt(index); newList.removeAt(index);
newList.insert(index, newEntryFinishedWaiting); newList.insert(index, newEntryFinishedWaiting);
await storage.writeEntriesForDate(forDate, newList);
storage.addFoodEntryToLookupDatabase(newEntryFinishedWaiting);
emit(PageState(foodEntries: newList)); emit(PageState(foodEntries: newList));
}); });
} }