Fix meal plan removal ignored on first attempt after app launch
Guard reconcileFromServer() with a syncStartTime so that entries modified locally during an active performSync() cycle are never overwritten by stale server data. This prevents the race condition where a user removes a meal plan entry while Phase 2 of sync is still iterating server recipes. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -65,6 +65,9 @@ class MealPlanSyncManager {
|
||||
func performSync() async {
|
||||
guard let appState, let mealPlanManager else { return }
|
||||
|
||||
mealPlanManager.syncStartTime = MealPlanDate.now()
|
||||
defer { mealPlanManager.syncStartTime = nil }
|
||||
|
||||
// Phase 1: Push locally-known meal plan state
|
||||
let localRecipeIds = Array(Set(
|
||||
mealPlanManager.entriesByDate.values.flatMap { $0 }.map(\.recipeId)
|
||||
|
||||
Reference in New Issue
Block a user