From caf25bc33f4c80c4cc9dc476152c113317a388a1 Mon Sep 17 00:00:00 2001 From: alexandrev-tibco Date: Thu, 18 Jun 2026 08:02:15 +0200 Subject: [PATCH] 1.1.5: auto-fill first week after onboarding Land new users on a ready, auto-planned week (with confetti) instead of an empty one, to improve activation. Only fires when the user added dishes; otherwise keeps the current empty-week + auto-assign prompt behavior. Co-Authored-By: Claude Opus 4.7 --- MealMood/ViewModels/OnboardingViewModel.swift | 8 +++++++- MealMood/Views/Home/HomeView.swift | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/MealMood/ViewModels/OnboardingViewModel.swift b/MealMood/ViewModels/OnboardingViewModel.swift index a99d240..bfbabb5 100644 --- a/MealMood/ViewModels/OnboardingViewModel.swift +++ b/MealMood/ViewModels/OnboardingViewModel.swift @@ -5,6 +5,7 @@ import SwiftData final class OnboardingViewModel: ObservableObject { static let pendingAutoAssignPromptKey = "onboarding_pending_auto_assign_prompt" static let pendingPremiumPromptKey = "onboarding_pending_premium_prompt" + static let pendingAutoFillOnLaunchKey = "onboarding_pending_auto_fill_on_launch" @Published var currentStep: Int = 0 @Published var selectedMealWindows: MealWindows = .dinnerOnly @@ -145,6 +146,7 @@ final class OnboardingViewModel: ObservableObject { let dish = Dish(name: dishData.name, tagIds: dishData.tagIds) context.insert(dish) } + let createdDishes = !addedDishes.isEmpty // Create first week plan let weekStart = Date().startOfWeek() @@ -153,7 +155,11 @@ final class OnboardingViewModel: ObservableObject { do { try context.save() AnalyticsService.logOnboardingCompleted() - UserDefaults.standard.set(true, forKey: Self.pendingAutoAssignPromptKey) + // If the user added dishes, auto-fill their first week on launch so they + // land on a ready plan instead of an empty one. Otherwise fall back to the + // home auto-assign prompt. + UserDefaults.standard.set(createdDishes, forKey: Self.pendingAutoFillOnLaunchKey) + UserDefaults.standard.set(!createdDishes, forKey: Self.pendingAutoAssignPromptKey) UserDefaults.standard.set(true, forKey: Self.pendingPremiumPromptKey) return true } catch { diff --git a/MealMood/Views/Home/HomeView.swift b/MealMood/Views/Home/HomeView.swift index 7928d33..4b01bf8 100644 --- a/MealMood/Views/Home/HomeView.swift +++ b/MealMood/Views/Home/HomeView.swift @@ -956,6 +956,17 @@ struct HomeView: View { guard !hasEvaluatedPostOnboardingPrompts else { return } hasEvaluatedPostOnboardingPrompts = true + // Auto-fill the first week so the user lands on a ready plan (with confetti) + // instead of being asked. Reuses the home's autoComplete choreography. + if UserDefaults.standard.bool(forKey: OnboardingViewModel.pendingAutoFillOnLaunchKey) { + UserDefaults.standard.set(false, forKey: OnboardingViewModel.pendingAutoFillOnLaunchKey) + if !dishes.isEmpty && plan.slots.contains(where: { $0.dishId == nil && !$0.isEatingOut }) { + viewModel.autoComplete(plan: plan, dishes: dishes, tags: tags, settings: settings, allPlans: weekPlans) + } + schedulePostOnboardingPremiumPromptIfNeeded(settings: settings) + return + } + let shouldAskAutoAssign = UserDefaults.standard.bool(forKey: OnboardingViewModel.pendingAutoAssignPromptKey) if shouldAskAutoAssign && plan.slots.contains(where: { $0.dishId == nil }) { showPostOnboardingAutoAssignPrompt = true