Skip to content

Commit 70b64bd

Browse files
committed
Only ask the user interactively once
1 parent 4773551 commit 70b64bd

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

extensions/gitpod/src/registerAuth.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,10 @@ function updateSyncContext() {
134134
*/
135135
export async function setSettingsSync(enabled?: boolean): Promise<void> {
136136
const config = vscode.workspace.getConfiguration();
137-
updateSyncContext();
138-
if (enabled) {
137+
if (!enabled) {
139138
try {
140139
await config.update('configurationSync.store', undefined, true);
141-
vscode.commands.executeCommand('setContext', 'gitpod.addedSyncProvider', false);
140+
updateSyncContext();
142141
promptToReload();
143142
} catch (e) {
144143
vscode.window.showErrorMessage(`Error setting up code sync config: ${e}`);
@@ -150,7 +149,7 @@ export async function setSettingsSync(enabled?: boolean): Promise<void> {
150149
const currentConfig = await config.get('configurationSync.store');
151150
if (JSON.stringify(currentConfig) !== JSON.stringify(newConfig)) {
152151
await config.update('configurationSync.store', newConfig, true);
153-
vscode.commands.executeCommand('setContext', 'gitpod.addedSyncProvider', true);
152+
updateSyncContext();
154153
promptToReload();
155154
}
156155
} catch (e) {
@@ -263,6 +262,22 @@ function createOauth2URL(options: { authorizationURI: string, clientID: string,
263262
return baseURL;
264263
}
265264

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+
266281
/**
267282
* Adds a authenthication provider to the provided extension context
268283
* @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
370385
}, { supportsMultipleAccounts: false }));
371386
logger('Pushed auth');
372387
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);
382389
}

0 commit comments

Comments
 (0)