mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +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 storageService = accessor.get(IStorageService);
|
||||||
const userDataSyncWorkbenchService = accessor.get(IUserDataSyncWorkbenchService);
|
const userDataSyncWorkbenchService = accessor.get(IUserDataSyncWorkbenchService);
|
||||||
const userDataSyncService = accessor.get(IUserDataSyncService);
|
const userDataSyncService = accessor.get(IUserDataSyncService);
|
||||||
|
const notificationService = accessor.get(INotificationService);
|
||||||
|
|
||||||
const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown';
|
try {
|
||||||
const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore;
|
const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown';
|
||||||
let userDataSyncStoreType: UserDataSyncStoreType | undefined;
|
const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore;
|
||||||
if (userDataSyncStore && isSwitchingToInsiders && userDataAutoSyncEnablementService.isEnabled()
|
let userDataSyncStoreType: UserDataSyncStoreType | undefined;
|
||||||
&& !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL, false)) {
|
if (userDataSyncStore && isSwitchingToInsiders && userDataAutoSyncEnablementService.isEnabled()
|
||||||
userDataSyncStoreType = await this.selectSettingsSyncService(dialogService);
|
&& !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL, false)) {
|
||||||
if (!userDataSyncStoreType) {
|
userDataSyncStoreType = await this.selectSettingsSyncService(dialogService);
|
||||||
return;
|
if (!userDataSyncStoreType) {
|
||||||
}
|
return;
|
||||||
storageService.store(selectSettingsSyncServiceDialogShownKey, true, StorageScope.GLOBAL, StorageTarget.USER);
|
}
|
||||||
if (userDataSyncStoreType === 'stable') {
|
storageService.store(selectSettingsSyncServiceDialogShownKey, true, StorageScope.GLOBAL, StorageTarget.USER);
|
||||||
// Update the stable service type in the current window, so that it uses stable service after switched to insiders version (after reload).
|
if (userDataSyncStoreType === 'stable') {
|
||||||
await userDataSyncStoreManagementService.switch(userDataSyncStoreType);
|
// 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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronise the store type option in insiders service, so that other clients using insiders service are also updated.
|
const res = await dialogService.confirm({
|
||||||
if (isSwitchingToInsiders) {
|
type: 'info',
|
||||||
promises.push(userDataSyncWorkbenchService.synchroniseUserDataSyncStoreType());
|
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);
|
// If sync is happening wait until it is finished before reload
|
||||||
} else {
|
if (userDataSyncService.status === SyncStatus.Syncing) {
|
||||||
// Reset
|
promises.push(Event.toPromise(Event.filter(userDataSyncService.onDidChangeStatus, status => status !== SyncStatus.Syncing)));
|
||||||
if (userDataSyncStoreType) {
|
}
|
||||||
storageService.remove(selectSettingsSyncServiceDialogShownKey, StorageScope.GLOBAL);
|
|
||||||
|
// 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