Keyword suggestions and language support.

This commit is contained in:
Vicnet
2023-10-10 13:37:46 +02:00
parent 6780868916
commit c0a63d7560
16 changed files with 986 additions and 169 deletions

View File

@@ -175,6 +175,17 @@ import SwiftUI
return nil
}
func getKeywords() async -> [String] {
if let keywords: [RecipeKeyword] = await self.loadObject(
localPath: "keywords.data",
networkPath: .KEYWORDS,
needsUpdate: true
) {
return keywords.map { $0.name }
}
return []
}
func deleteAllData() {
if dataStore.clearAll() {
self.categories = []
@@ -183,6 +194,16 @@ import SwiftUI
self.recipeDetails = [:]
}
}
func deleteRecipe(withId id: Int, categoryName: String) {
let path = "recipe\(id).data"
dataStore.delete(path: path)
guard recipes[categoryName] != nil else { return }
recipes[categoryName]!.removeAll(where: { recipe in
recipe.recipe_id == id ? true : false
})
recipeDetails.removeValue(forKey: id)
}
}