diff options
author | davidpkj <davidpenkow1@gmail.com> | 2022-08-24 15:38:58 +0200 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2022-08-24 15:38:58 +0200 |
commit | 33bb197557b6222d7db46e02c74fe8442833e295 (patch) | |
tree | 017036dc57cce28fac92aedbcad65249d4f4d1c1 /lib/models | |
parent | e18cf14cc7d586a90283cf50678b6d53474ef3b8 (diff) |
Minor bug fixes and updates
Diffstat (limited to 'lib/models')
-rw-r--r-- | lib/models/data/recipe_data_class.dart | 15 | ||||
-rw-r--r-- | lib/models/data/settings_data_class.dart | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/models/data/recipe_data_class.dart b/lib/models/data/recipe_data_class.dart index fd4ef22..3f707bc 100644 --- a/lib/models/data/recipe_data_class.dart +++ b/lib/models/data/recipe_data_class.dart @@ -38,14 +38,25 @@ class RecipeData { if (_result.isEmpty) return; + recipesIdentical(Recipe a, Recipe b) { + if (a.title != b.title) return false; + if (a.description != b.description) return false; + + return true; + } + _result.forEach((item) { - recipeList.add(Recipe( + Recipe recipe = Recipe( title: item["title"], description: item["description"], favorite: item["favorite"], rating: item["rating"], image: item["image"], - )); + ); + + if (RecipeData.recipeList.where((element) => recipesIdentical(element, recipe)).isEmpty) recipeList.add(recipe); }); + + save(); } } diff --git a/lib/models/data/settings_data_class.dart b/lib/models/data/settings_data_class.dart index e8cd604..5d3de60 100644 --- a/lib/models/data/settings_data_class.dart +++ b/lib/models/data/settings_data_class.dart @@ -29,5 +29,7 @@ class SettingsData { _result.forEach((key, value) { settings[key] = value; }); + + save(); } } |