From bbc2da76a9798c2f8a562af56ac41c5a420a7e37 Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Wed, 15 Jan 2020 01:51:35 +0100 Subject: [PATCH] fix token check --- .../userDataSync/browser/userDataSync.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index 5d87233cb66..0f7b0c92f7c 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -364,6 +364,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo if (this.authenticationState.get() === MSAAuthStatus.SignedOut) { await this.signIn(); } + + await this.handleFirstTimeSync(); await this.configurationService.updateValue(UserDataSyncWorkbenchContribution.ENABLEMENT_SETTING, true); this.notificationService.info(localize('Sync Started', "Sync Started.")); } @@ -413,6 +415,34 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo }); } + private async handleFirstTimeSync(): Promise { + + const hasRemote = await this.userDataSyncService.hasRemote(); + const hasPreviouslySynced = await this.userDataSyncService.hasPreviouslySynced(); + + if (hasRemote && !hasPreviouslySynced) { + const result = await this.dialogService.show( + Severity.Info, + localize('firs time sync', "First time synchronization"), + [ + localize('continue', "Continue"), + localize('cancel', "Cancel"), + localize('download', "Download"), + localize('upload', "Upload"), + ], + { + cancelId: 1, + detail: localize('first time sync detail', "Synchronising from this device for the first time. Would you like to \nDownload and replace with the remote data or \nUpload from this device and replace the remote data?") + } + ); + + switch (result.choice) { + case 2: return this.userDataSyncService.pull(); + case 3: return this.userDataSyncService.push(); + } + } + } + private async turnOff(): Promise { const result = await this.dialogService.confirm({ type: 'info', -- GitLab