Fixed: edited recipes were not saved locally

This commit is contained in:
VincentMeilinger
2024-03-08 17:45:26 +01:00
parent dbe626d595
commit 29872611da
3 changed files with 8 additions and 1 deletions

View File

@@ -189,7 +189,7 @@ import UIKit
```swift
let recipeDetail = await mainViewModel.getRecipe(id: 123)
*/
func getRecipe(id: Int, fetchMode: FetchMode) async -> RecipeDetail? {
func getRecipe(id: Int, fetchMode: FetchMode, save: Bool = false) async -> RecipeDetail? {
func getLocal() async -> RecipeDetail? {
if let recipe: RecipeDetail = await loadLocal(path: "recipe\(id).data") { return recipe }
return nil
@@ -201,6 +201,10 @@ import UIKit
id: id
)
if let recipe = recipe {
if save {
self.recipeDetails[id] = recipe
await self.saveLocal(recipe, path: "recipe\(id).data")
}
return recipe
} else if let error = error {
print(error)