mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
fix #96370
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { IUserDataSyncService, IUserDataSyncEnablementService, IAuthenticationProvider, getUserDataSyncStore, isAuthenticationProvider } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE, SHOW_SYNCED_DATA_COMMAND_ID } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
import { AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/editor/common/modes';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
@@ -26,6 +26,7 @@ import { canceled } from 'vs/base/common/errors';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
|
||||
type UserAccountClassification = {
|
||||
id: { classification: 'EndUserPseudonymizedInformation', purpose: 'BusinessInsight' };
|
||||
@@ -89,6 +90,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IDialogService private readonly dialogService: IDialogService,
|
||||
@ICommandService private readonly commandService: ICommandService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
) {
|
||||
super();
|
||||
@@ -235,31 +237,36 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
}
|
||||
|
||||
private async handleFirstTimeSync(): Promise<void> {
|
||||
const isFirstSyncWithMerge = await this.userDataSyncService.isFirstTimeSyncWithMerge();
|
||||
if (!isFirstSyncWithMerge) {
|
||||
const isFirstTimeSyncingWithAnotherMachine = await this.userDataSyncService.isFirstTimeSyncingWithAnotherMachine();
|
||||
if (!isFirstTimeSyncingWithAnotherMachine) {
|
||||
return;
|
||||
}
|
||||
const result = await this.dialogService.show(
|
||||
Severity.Info,
|
||||
localize('firs time sync', "Sync"),
|
||||
localize('Replace or Merge', "Replace or Merge"),
|
||||
[
|
||||
localize('merge', "Merge"),
|
||||
localize('show synced data', "Show Synced Data"),
|
||||
localize('cancel', "Cancel"),
|
||||
localize('replace', "Replace Local"),
|
||||
localize('merge', "Merge"),
|
||||
localize('replace local', "Replace Local"),
|
||||
],
|
||||
{
|
||||
cancelId: 1,
|
||||
detail: localize('first time sync detail', "It looks like this is the first time sync is set up.\nWould you like to merge or replace with the data from the cloud?"),
|
||||
detail: localize('first time sync detail', "It looks like you last synced from another machine.\nWould you like to replace or merge with the synced data?"),
|
||||
}
|
||||
);
|
||||
switch (result.choice) {
|
||||
case 0:
|
||||
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'merge' });
|
||||
break;
|
||||
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'showSyncedData' });
|
||||
await this.commandService.executeCommand(SHOW_SYNCED_DATA_COMMAND_ID);
|
||||
throw canceled();
|
||||
case 1:
|
||||
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'cancelled' });
|
||||
throw canceled();
|
||||
case 2:
|
||||
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'merge' });
|
||||
break;
|
||||
case 3:
|
||||
this.telemetryService.publicLog2<{ action: string }, FirstTimeSyncClassification>('sync/firstTimeSync', { action: 'replace-local' });
|
||||
await this.userDataSyncService.pull();
|
||||
break;
|
||||
|
||||
@@ -57,3 +57,4 @@ export const CONTEXT_ENABLE_VIEWS = new RawContextKey<boolean>(`showUserDataSync
|
||||
export const ENABLE_SYNC_VIEWS_COMMAND_ID = 'workbench.userDataSync.actions.enableViews';
|
||||
export const CONFIGURE_SYNC_COMMAND_ID = 'workbench.userDataSync.actions.configure';
|
||||
export const SHOW_SYNC_LOG_COMMAND_ID = 'workbench.userDataSync.actions.showLog';
|
||||
export const SHOW_SYNCED_DATA_COMMAND_ID = 'workbench.userDataSync.actions.showSyncedData';
|
||||
|
||||
@@ -89,8 +89,8 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
|
||||
return this.channel.call('resetLocal');
|
||||
}
|
||||
|
||||
isFirstTimeSyncWithMerge(): Promise<boolean> {
|
||||
return this.channel.call('isFirstTimeSyncWithMerge');
|
||||
isFirstTimeSyncingWithAnotherMachine(): Promise<boolean> {
|
||||
return this.channel.call('isFirstTimeSyncingWithAnotherMachine');
|
||||
}
|
||||
|
||||
acceptConflict(conflict: URI, content: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user