mirror of
https://github.com/Microsoft/vscode
synced 2024-07-17 02:57:19 +00:00
fix switching to insiders when settings sync is disabled
This commit is contained in:
parent
d9cc12292d
commit
c35100aba3
|
@ -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<any>[] = [];
|
||||
|
||||
// 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<any>[] = [];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue