Skip to content

Commit

Permalink
fix: moved default vault selection to RestoreBackupView
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldavidw committed Jun 23, 2024
1 parent 4cb3d96 commit 0d09344
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Chronos/App/Onboarding/Restore/RestoreBackupView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Factory
import SwiftData
import SwiftUI

struct RestoreBackupView: View {
Expand All @@ -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?
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions Chronos/App/Onboarding/WelcomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 0d09344

Please sign in to comment.