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 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-06-18 08:02:15 +02:00
parent 82d623aa05
commit caf25bc33f
2 changed files with 18 additions and 1 deletions
@@ -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 {
+11
View File
@@ -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