From 970cea8ba728eb4cc0eb7b70c052c6c7fc192d53 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 2 Oct 2024 16:22:33 +0200 Subject: [PATCH] Oops, forgot to store the entries that were scanned. They just disappeared after restarting the app --- lib/food_entry/food_entry_bloc.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/food_entry/food_entry_bloc.dart b/lib/food_entry/food_entry_bloc.dart index f40cbf5..44bd89f 100644 --- a/lib/food_entry/food_entry_bloc.dart +++ b/lib/food_entry/food_entry_bloc.dart @@ -84,7 +84,7 @@ class FoodEntryBloc extends Bloc { newList.add(newEntryWaiting); emit(PageState(foodEntries: newList)); - await responseFuture.then((response) { + await responseFuture.then((response) async { var index = newList .indexWhere((entryState) => entryState.id == newEntryWaiting.id); @@ -117,6 +117,10 @@ class FoodEntryBloc extends Bloc { newList.removeAt(index); newList.insert(index, newEntryFinishedWaiting); + + await storage.writeEntriesForDate(forDate, newList); + storage.addFoodEntryToLookupDatabase(newEntryFinishedWaiting); + emit(PageState(foodEntries: newList)); }); }