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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user