diff --git a/src/vs/workbench/contrib/update/browser/update.ts b/src/vs/workbench/contrib/update/browser/update.ts index 2138c3827ba..1547ad559f3 100644 --- a/src/vs/workbench/contrib/update/browser/update.ts +++ b/src/vs/workbench/contrib/update/browser/update.ts @@ -529,53 +529,58 @@ export class SwitchProductQualityContribution extends Disposable implements IWor const storageService = accessor.get(IStorageService); const userDataSyncWorkbenchService = accessor.get(IUserDataSyncWorkbenchService); const userDataSyncService = accessor.get(IUserDataSyncService); + const notificationService = accessor.get(INotificationService); - const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown'; - const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore; - let userDataSyncStoreType: UserDataSyncStoreType | undefined; - if (userDataSyncStore && isSwitchingToInsiders && userDataAutoSyncEnablementService.isEnabled() - && !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL, false)) { - userDataSyncStoreType = await this.selectSettingsSyncService(dialogService); - if (!userDataSyncStoreType) { - return; - } - storageService.store(selectSettingsSyncServiceDialogShownKey, true, StorageScope.GLOBAL, StorageTarget.USER); - if (userDataSyncStoreType === 'stable') { - // Update the stable service type in the current window, so that it uses stable service after switched to insiders version (after reload). - await userDataSyncStoreManagementService.switch(userDataSyncStoreType); - } - } - - const res = await dialogService.confirm({ - type: 'info', - message: nls.localize('relaunchMessage', "Changing the version requires a reload to take effect"), - detail: newQuality === 'insider' ? - nls.localize('relaunchDetailInsiders', "Press the reload button to switch to the nightly pre-production version of VSCode.") : - nls.localize('relaunchDetailStable', "Press the reload button to switch to the monthly released stable version of VSCode."), - primaryButton: nls.localize('reload', "&&Reload") - }); - - if (res.confirmed) { - const promises: Promise[] = []; - - // If sync is happening wait until it is finished before reload - if (userDataSyncService.status === SyncStatus.Syncing) { - promises.push(Event.toPromise(Event.filter(userDataSyncService.onDidChangeStatus, status => status !== SyncStatus.Syncing))); + try { + const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown'; + const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore; + let userDataSyncStoreType: UserDataSyncStoreType | undefined; + if (userDataSyncStore && isSwitchingToInsiders && userDataAutoSyncEnablementService.isEnabled() + && !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL, false)) { + userDataSyncStoreType = await this.selectSettingsSyncService(dialogService); + if (!userDataSyncStoreType) { + return; + } + storageService.store(selectSettingsSyncServiceDialogShownKey, true, StorageScope.GLOBAL, StorageTarget.USER); + if (userDataSyncStoreType === 'stable') { + // Update the stable service type in the current window, so that it uses stable service after switched to insiders version (after reload). + await userDataSyncStoreManagementService.switch(userDataSyncStoreType); + } } - // Synchronise the store type option in insiders service, so that other clients using insiders service are also updated. - if (isSwitchingToInsiders) { - promises.push(userDataSyncWorkbenchService.synchroniseUserDataSyncStoreType()); - } + const res = await dialogService.confirm({ + type: 'info', + message: nls.localize('relaunchMessage', "Changing the version requires a reload to take effect"), + detail: newQuality === 'insider' ? + nls.localize('relaunchDetailInsiders', "Press the reload button to switch to the nightly pre-production version of VSCode.") : + nls.localize('relaunchDetailStable', "Press the reload button to switch to the monthly released stable version of VSCode."), + primaryButton: nls.localize('reload', "&&Reload") + }); - await Promises.settled(promises); + if (res.confirmed) { + const promises: Promise[] = []; - productQualityChangeHandler(newQuality); - } else { - // Reset - if (userDataSyncStoreType) { - storageService.remove(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL); + // If sync is happening wait until it is finished before reload + if (userDataSyncService.status === SyncStatus.Syncing) { + promises.push(Event.toPromise(Event.filter(userDataSyncService.onDidChangeStatus, status => status !== SyncStatus.Syncing))); + } + + // If user chose the sync service then synchronise the store type option in insiders service, so that other clients using insiders service are also updated. + if (isSwitchingToInsiders && userDataSyncStoreType) { + promises.push(userDataSyncWorkbenchService.synchroniseUserDataSyncStoreType()); + } + + await Promises.settled(promises); + + productQualityChangeHandler(newQuality); + } else { + // Reset + if (userDataSyncStoreType) { + storageService.remove(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL); + } } + } catch (error) { + notificationService.error(error); } }