Skip to content

Commit 4529b4a

Browse files
authored
Fix Cloud Changes enablement placeholder (microsoft#187761)
1 parent ae0d63d commit 4529b4a

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

src/vs/workbench/contrib/editSessions/browser/editSessions.contribution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
227227
) {
228228
// store the fact that we prompted the user
229229
this.storageService.store(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.MACHINE);
230-
await this.editSessionsStorageService.initialize();
230+
await this.editSessionsStorageService.initialize('read');
231231
if (this.editSessionsStorageService.isSignedIn) {
232232
await this.progressService.withProgress(resumeProgressOptions, async (progress) => await this.resumeEditSession(undefined, true, undefined, undefined, progress));
233233
} else {
@@ -491,7 +491,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
491491

492492
this.logService.info(ref !== undefined ? `Resuming changes from cloud with ref ${ref}...` : 'Checking for pending cloud changes...');
493493

494-
if (silent && !(await this.editSessionsStorageService.initialize(true))) {
494+
if (silent && !(await this.editSessionsStorageService.initialize('read', true))) {
495495
return;
496496
}
497497

@@ -838,7 +838,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
838838
return continueWithCloudChanges;
839839
}
840840

841-
const initialized = await this.editSessionsStorageService.initialize();
841+
const initialized = await this.editSessionsStorageService.initialize('write');
842842
if (!initialized) {
843843
this.telemetryService.publicLog2<EditSessionsAuthCheckEvent, EditSessionsAuthCheckClassification>('continueOn.editSessions.canStore.outcome', { outcome: 'didNotEnableEditSessionsWhenPrompted' });
844844
}

src/vs/workbench/contrib/editSessions/browser/editSessionsStorageService.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
106106
* @returns The ref of the stored state.
107107
*/
108108
async write(resource: SyncResource, content: string | EditSession): Promise<string> {
109-
await this.initialize(false);
109+
await this.initialize('write', false);
110110
if (!this.initialized) {
111111
throw new Error('Please sign in to store your edit session.');
112112
}
@@ -131,7 +131,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
131131
* @returns An object representing the requested or latest state, if any.
132132
*/
133133
async read(resource: SyncResource, ref: string | undefined): Promise<{ ref: string; content: string } | undefined> {
134-
await this.initialize(false);
134+
await this.initialize('read', false);
135135
if (!this.initialized) {
136136
throw new Error('Please sign in to apply your latest edit session.');
137137
}
@@ -159,7 +159,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
159159
}
160160

161161
async delete(resource: SyncResource, ref: string | null) {
162-
await this.initialize(false);
162+
await this.initialize('write', false);
163163
if (!this.initialized) {
164164
throw new Error(`Unable to delete edit session with ref ${ref}.`);
165165
}
@@ -172,7 +172,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
172172
}
173173

174174
async list(resource: SyncResource): Promise<IResourceRefHandle[]> {
175-
await this.initialize(false);
175+
await this.initialize('read', false);
176176
if (!this.initialized) {
177177
throw new Error(`Unable to list edit sessions.`);
178178
}
@@ -186,11 +186,11 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
186186
return [];
187187
}
188188

189-
public async initialize(silent: boolean = false) {
189+
public async initialize(reason: 'read' | 'write', silent: boolean = false) {
190190
if (this.initialized) {
191191
return true;
192192
}
193-
this.initialized = await this.doInitialize(silent);
193+
this.initialized = await this.doInitialize(reason, silent);
194194
this.signedInContext.set(this.initialized);
195195
if (this.initialized) {
196196
this._didSignIn.fire();
@@ -205,7 +205,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
205205
* meaning that authentication is configured and it
206206
* can be used to communicate with the remote storage service
207207
*/
208-
private async doInitialize(silent: boolean): Promise<boolean> {
208+
private async doInitialize(reason: 'read' | 'write', silent: boolean): Promise<boolean> {
209209
// Wait for authentication extensions to be registered
210210
await this.extensionService.whenInstalledExtensionsRegistered();
211211

@@ -231,7 +231,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
231231
return true;
232232
}
233233

234-
const authenticationSession = await this.getAuthenticationSession(silent);
234+
const authenticationSession = await this.getAuthenticationSession(reason, silent);
235235
if (authenticationSession !== undefined) {
236236
this.authenticationInfo = authenticationSession;
237237
this.storeClient.setAuthToken(authenticationSession.token, authenticationSession.providerId);
@@ -243,7 +243,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
243243
private cachedMachines: Map<string, string> | undefined;
244244

245245
async getMachineById(machineId: string) {
246-
await this.initialize(false);
246+
await this.initialize('read', false);
247247

248248
if (!this.cachedMachines) {
249249
const machines = await this.machineClient!.getMachines();
@@ -264,7 +264,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
264264
return currentMachineId;
265265
}
266266

267-
private async getAuthenticationSession(silent: boolean) {
267+
private async getAuthenticationSession(reason: 'read' | 'write', silent: boolean) {
268268
// If the user signed in previously and the session is still available, reuse that without prompting the user again
269269
if (this.existingSessionId) {
270270
this.logService.info(`Searching for existing authentication session with ID ${this.existingSessionId}`);
@@ -295,7 +295,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
295295
}
296296

297297
// Ask the user to pick a preferred account
298-
const authenticationSession = await this.getAccountPreference();
298+
const authenticationSession = await this.getAccountPreference(reason);
299299
if (authenticationSession !== undefined) {
300300
this.existingSessionId = authenticationSession.id;
301301
return { sessionId: authenticationSession.id, token: authenticationSession.idToken ?? authenticationSession.accessToken, providerId: authenticationSession.providerId };
@@ -312,10 +312,10 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
312312
*
313313
* Prompts the user to pick an authentication option for storing and getting edit sessions.
314314
*/
315-
private async getAccountPreference(): Promise<AuthenticationSession & { providerId: string } | undefined> {
315+
private async getAccountPreference(reason: 'read' | 'write'): Promise<AuthenticationSession & { providerId: string } | undefined> {
316316
const quickpick = this.quickInputService.createQuickPick<ExistingSession | AuthenticationProviderOption | IQuickPickItem>();
317317
quickpick.ok = false;
318-
quickpick.placeholder = localize('choose account placeholder', "Select an account to store your working changes in the cloud");
318+
quickpick.placeholder = reason === 'read' ? localize('choose account read placeholder', "Select an account to restore your working changes from the cloud") : localize('choose account placeholder', "Select an account to store your working changes in the cloud");
319319
quickpick.ignoreFocusOut = true;
320320
quickpick.items = await this.createQuickpickItems();
321321

@@ -482,7 +482,7 @@ export class EditSessionsWorkbenchService extends Disposable implements IEditSes
482482
}
483483

484484
async run() {
485-
return await that.initialize(false);
485+
return await that.initialize('write', false);
486486
}
487487
}));
488488

src/vs/workbench/contrib/editSessions/common/editSessions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface IEditSessionsStorageService {
3838
lastReadResources: Map<SyncResource, { ref: string; content: string }>;
3939
lastWrittenResources: Map<SyncResource, { ref: string; content: string }>;
4040

41-
initialize(silent?: boolean): Promise<boolean>;
41+
initialize(reason: 'read' | 'write', silent?: boolean): Promise<boolean>;
4242
read(resource: SyncResource, ref: string | undefined): Promise<{ ref: string; content: string } | undefined>;
4343
write(resource: SyncResource, content: string | EditSession): Promise<string>;
4444
delete(resource: SyncResource, ref: string | null): Promise<void>;

0 commit comments

Comments
 (0)