@@ -134,11 +134,10 @@ function updateSyncContext() {
134
134
*/
135
135
export async function setSettingsSync ( enabled ?: boolean ) : Promise < void > {
136
136
const config = vscode . workspace . getConfiguration ( ) ;
137
- updateSyncContext ( ) ;
138
- if ( enabled ) {
137
+ if ( ! enabled ) {
139
138
try {
140
139
await config . update ( 'configurationSync.store' , undefined , true ) ;
141
- vscode . commands . executeCommand ( 'setContext' , 'gitpod.addedSyncProvider' , false ) ;
140
+ updateSyncContext ( ) ;
142
141
promptToReload ( ) ;
143
142
} catch ( e ) {
144
143
vscode . window . showErrorMessage ( `Error setting up code sync config: ${ e } ` ) ;
@@ -150,7 +149,7 @@ export async function setSettingsSync(enabled?: boolean): Promise<void> {
150
149
const currentConfig = await config . get ( 'configurationSync.store' ) ;
151
150
if ( JSON . stringify ( currentConfig ) !== JSON . stringify ( newConfig ) ) {
152
151
await config . update ( 'configurationSync.store' , newConfig , true ) ;
153
- vscode . commands . executeCommand ( 'setContext' , 'gitpod.addedSyncProvider' , true ) ;
152
+ updateSyncContext ( ) ;
154
153
promptToReload ( ) ;
155
154
}
156
155
} catch ( e ) {
@@ -263,6 +262,22 @@ function createOauth2URL(options: { authorizationURI: string, clientID: string,
263
262
return baseURL ;
264
263
}
265
264
265
+ /**
266
+ * Asks the user to setup Settings Sync
267
+ * @param context the extension context
268
+ */
269
+ async function askToEnable ( context : vscode . ExtensionContext ) : Promise < void > {
270
+ if ( ! await context . secrets . get ( 'gitpod.syncPopupShown' ) ) {
271
+ vscode . window . showInformationMessage ( 'Would you like to use Settings Sync with Gitpod?' , 'Yes' , 'No' )
272
+ . then ( async selectedAction => {
273
+ await context . secrets . store ( 'gitpod.syncPopupShown' , 'true' ) ;
274
+ if ( selectedAction === 'Yes' ) {
275
+ setSettingsSync ( true ) ;
276
+ }
277
+ } ) ;
278
+ }
279
+ }
280
+
266
281
/**
267
282
* Adds a authenthication provider to the provided extension context
268
283
* @param context the extension context to act upon and the context to which push the authenthication service
@@ -370,13 +385,5 @@ export function registerAuth(context: vscode.ExtensionContext, logger: (value: s
370
385
} , { supportsMultipleAccounts : false } ) ) ;
371
386
logger ( 'Pushed auth' ) ;
372
387
updateSyncContext ( ) ;
373
- const enabledSettingsSync = vscode . workspace . getConfiguration ( ) . get ( 'configurationSync.store' ) ;
374
- if ( enabledSettingsSync === undefined || JSON . stringify ( enabledSettingsSync ) === '{}' ) {
375
- vscode . window . showInformationMessage ( 'Would you like to use Settings Sync with Gitpod?' , 'Yes' , 'No' )
376
- . then ( selectedAction => {
377
- if ( selectedAction === 'Yes' ) {
378
- setSettingsSync ( true ) ;
379
- }
380
- } ) ;
381
- }
388
+ askToEnable ( context ) ;
382
389
}
0 commit comments