From 0d093444bac87148ca9dc954bdb6876e7d11be60 Mon Sep 17 00:00:00 2001 From: Joel-David Date: Sun, 23 Jun 2024 17:48:15 +0800 Subject: [PATCH] fix: moved default vault selection to RestoreBackupView --- Chronos/App/Onboarding/Restore/RestoreBackupView.swift | 9 +++++++++ Chronos/App/Onboarding/WelcomeView.swift | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Chronos/App/Onboarding/Restore/RestoreBackupView.swift b/Chronos/App/Onboarding/Restore/RestoreBackupView.swift index f8ba0ee..75eca02 100644 --- a/Chronos/App/Onboarding/Restore/RestoreBackupView.swift +++ b/Chronos/App/Onboarding/Restore/RestoreBackupView.swift @@ -1,4 +1,5 @@ import Factory +import SwiftData import SwiftUI struct RestoreBackupView: View { @@ -8,6 +9,8 @@ struct RestoreBackupView: View { @State private var passwordInvalid: Bool = false @State private var backupExists: Bool = false + @Query var vaults: [Vault] + @AppStorage(StateEnum.ICLOUD_BACKUP_ENABLED.rawValue) var isICloudEnabled: Bool = false @FocusState private var focusedField: FocusedField? @@ -53,6 +56,12 @@ struct RestoreBackupView: View { Spacer() Button { + // Defaults to the first vault if the user is not coming from VaultSelectionView. + // Users will only come from VaultSelectionView if there are multiple vaults. + if vaults.count == 1 { + stateService.setVaultId(vaultId: vaults.first!.vaultId!) + } + restoreBtnPressed = true Task { diff --git a/Chronos/App/Onboarding/WelcomeView.swift b/Chronos/App/Onboarding/WelcomeView.swift index 5e99224..c0b6948 100644 --- a/Chronos/App/Onboarding/WelcomeView.swift +++ b/Chronos/App/Onboarding/WelcomeView.swift @@ -56,10 +56,6 @@ struct WelcomeView: View { } else { if hasSynced { Button(action: { - if vaults.count == 1 { - stateService.setVaultId(vaultId: vaults.first!.vaultId!) - } - restorePressed = true }) { Text("Restore from iCloud")