Skip to content

Commit

Permalink
Make switch accounts fun async
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme committed Dec 19, 2024
1 parent b03c8a9 commit f838c7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate {
preferredStyle: .alert)
alertController.addAction(title: UserText.syncAlertSwitchAccountButton, style: .default) { [weak self] in
self?.switchAccounts(recoveryKey: recoveryKey)
Task {
await self?.switchAccounts(recoveryKey: recoveryKey)
}
}
alertController.addAction(title: UserText.actionCancel, style: .cancel)
// Gives time to the is syncing view to appear
Expand All @@ -200,7 +203,7 @@ extension SyncSettingsViewController: SyncManagementViewModelDelegate {
}
}

func switchAccounts(recoveryKey: SyncCode.RecoveryKey) {
func switchAccounts(recoveryKey: SyncCode.RecoveryKey) async {
Task { [weak self] in
do {
try await self?.syncService.disconnect()
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/SyncSettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ extension SyncSettingsViewController: ScanOrPasteCodeViewModelDelegate {
if rootView.model.devices.count > 1 {
promptToSwitchAccounts(recoveryKey: recoveryKey)
} else {
switchAccounts(recoveryKey: recoveryKey)
await switchAccounts(recoveryKey: recoveryKey)
}
} else {
handleError(.unableToSyncToServer, error: error, event: .syncLoginError)
Expand Down

0 comments on commit f838c7a

Please sign in to comment.