From f838c7aca0dbabed057ae23b372e81c831ae74ed Mon Sep 17 00:00:00 2001 From: Graeme Arthur Date: Thu, 19 Dec 2024 15:22:02 +0100 Subject: [PATCH] Make switch accounts fun async --- DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift | 5 ++++- DuckDuckGo/SyncSettingsViewController.swift | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift b/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift index 70a8635dcb..a9621934d3 100644 --- a/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift +++ b/DuckDuckGo/SyncSettingsViewController+SyncDelegate.swift @@ -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 @@ -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() diff --git a/DuckDuckGo/SyncSettingsViewController.swift b/DuckDuckGo/SyncSettingsViewController.swift index 09104e42c7..d34e57c182 100644 --- a/DuckDuckGo/SyncSettingsViewController.swift +++ b/DuckDuckGo/SyncSettingsViewController.swift @@ -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)