Add cross-device grocery list sync via Nextcloud Cookbook API
Store a _groceryState JSON field on each recipe to track which ingredients have been added, completed, or removed. Uses per-item last-writer-wins conflict resolution with ISO 8601 timestamps. Debounced push (2s) avoids excessive API calls; pull reconciles on recipe open and app launch. Includes a settings toggle to enable/disable sync. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,8 @@ class ObservableRecipeDetail: ObservableObject {
|
||||
@Published var recipeIngredient: [String]
|
||||
@Published var recipeInstructions: [String]
|
||||
@Published var nutrition: [String:String]
|
||||
|
||||
var groceryState: GroceryState?
|
||||
|
||||
// Additional functionality
|
||||
@Published var ingredientMultiplier: Double
|
||||
|
||||
@@ -48,7 +49,8 @@ class ObservableRecipeDetail: ObservableObject {
|
||||
recipeIngredient = []
|
||||
recipeInstructions = []
|
||||
nutrition = [:]
|
||||
|
||||
groceryState = nil
|
||||
|
||||
ingredientMultiplier = 1
|
||||
}
|
||||
|
||||
@@ -68,7 +70,8 @@ class ObservableRecipeDetail: ObservableObject {
|
||||
recipeIngredient = recipeDetail.recipeIngredient
|
||||
recipeInstructions = recipeDetail.recipeInstructions
|
||||
nutrition = recipeDetail.nutrition
|
||||
|
||||
groceryState = recipeDetail.groceryState
|
||||
|
||||
ingredientMultiplier = Double(recipeDetail.recipeYield == 0 ? 1 : recipeDetail.recipeYield)
|
||||
}
|
||||
|
||||
@@ -90,7 +93,8 @@ class ObservableRecipeDetail: ObservableObject {
|
||||
tool: self.tool,
|
||||
recipeIngredient: self.recipeIngredient,
|
||||
recipeInstructions: self.recipeInstructions,
|
||||
nutrition: self.nutrition
|
||||
nutrition: self.nutrition,
|
||||
groceryState: self.groceryState
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user