Skip to content

Commit

Permalink
fix: Add item to shopping list when the description is changed (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBursch authored Jul 30, 2023
1 parent e975bbe commit 592d7e4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/services/transactions/shoppinglist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ class TransactionShoppingListUpdateItem extends Transaction<bool> {
);
TempStorage.getInstance().writeItems(shoppinglist, list);

return true;
} else if (description.isNotEmpty) {
final list =
await TempStorage.getInstance().readItems(shoppinglist) ?? [];
list.add(ShoppinglistItem(name: item.name, description: description));
TempStorage.getInstance().writeItems(shoppinglist, list);

return true;
}

Expand All @@ -367,6 +374,9 @@ class TransactionShoppingListUpdateItem extends Transaction<bool> {
if (item is ShoppinglistItem) {
return ApiService.getInstance()
.updateShoppingListItemDescription(shoppinglist, item, description);
} else if (description.isNotEmpty) {
ApiService.getInstance()
.addItemByName(shoppinglist, item.name, description);
}

return false;
Expand Down

0 comments on commit 592d7e4

Please sign in to comment.