Skip to content

Commit

Permalink
updated onboarding. prevent removal of all tokens and cryptos
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldavidw committed Jun 15, 2024
1 parent 4a9fc83 commit 5482e43
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
14 changes: 5 additions & 9 deletions Chronos/App/Onboarding/StorageSetupView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,17 @@ struct StorageSetupView: View {
.navigationDestination(isPresented: $nextBtnPressed) {
PasswordSetupView()
}
.confirmationDialog("Backup Exists", isPresented: $showICloudOverwriteConfirmation, titleVisibility: .visible) {
Button("Remove & Continue", role: .destructive, action: {
let cryptoDeleted = swiftDataService.deleteCloudChronosCryptoData()

if cryptoDeleted {
isICloudEnabled = true
nextBtnPressed = true
}
.confirmationDialog("Vault Exists", isPresented: $showICloudOverwriteConfirmation, titleVisibility: .visible) {
Button("Continue", role: .destructive, action: {
isICloudEnabled = true
nextBtnPressed = true
})

Button("Cancel", role: .cancel, action: {
self.showICloudOverwriteConfirmation = false
})
} message: {
Text("A Chronos backup already exists in iCloud. Are you sure you want to remove all data?")
Text("A vault already exists in iCloud. Are you sure you want to create a new one?")
}
}
}
9 changes: 0 additions & 9 deletions Chronos/Services/SwiftDataService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,4 @@ extension SwiftDataService {
getCloudModelContainer().deleteAllData()
resetModelContainers()
}

func deleteCloudChronosCryptoData() -> Bool {
let container = getCloudModelContainer()
let modelContext = ModelContext(container)
try? modelContext.delete(model: ChronosCrypto.self)
try? modelContext.delete(model: EncryptedToken.self)
try? modelContext.save()
return true
}
}

0 comments on commit 5482e43

Please sign in to comment.