Skip to content

Commit b891aa2

Browse files
authored
Don't show account badge if user already actioned Edit Sessions via Continue On once (microsoft#162373)
Fix microsoft#162301
1 parent 203b26d commit b891aa2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,33 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
144144
};
145145
this.telemetryService.publicLog2<ResumeEvent, ResumeClassification>('editSessions.continue.resume');
146146

147+
const shouldAutoResumeOnReload = this.configurationService.getValue('workbench.editSessions.autoResume') === 'onReload';
148+
147149
if (this.environmentService.editSessionId !== undefined) {
148150
this.logService.info(`Resuming edit session, reason: found editSessionId ${this.environmentService.editSessionId} in environment service...`);
149151
await this.resumeEditSession(this.environmentService.editSessionId).finally(() => this.environmentService.editSessionId = undefined);
150-
} else if (
151-
this.configurationService.getValue('workbench.editSessions.autoResume') === 'onReload' &&
152-
this.editSessionsStorageService.isSignedIn
153-
) {
152+
} else if (shouldAutoResumeOnReload && this.editSessionsStorageService.isSignedIn) {
154153
this.logService.info('Resuming edit session, reason: edit sessions enabled...');
155154
// Attempt to resume edit session based on edit workspace identifier
156155
// Note: at this point if the user is not signed into edit sessions,
157156
// we don't want them to be prompted to sign in and should just return early
158157
await this.resumeEditSession(undefined, true);
159-
} else {
158+
} else if (shouldAutoResumeOnReload) {
160159
// The application has previously launched via a protocol URL Continue On flow
161160
const hasApplicationLaunchedFromContinueOnFlow = this.storageService.getBoolean(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, StorageScope.APPLICATION, false);
162161

162+
const handlePendingEditSessions = () => {
163+
// display a badge in the accounts menu but do not prompt the user to sign in again
164+
this.updateAccountsMenuBadge();
165+
// attempt a resume if we are in a pending state and the user just signed in
166+
const disposable = this.editSessionsStorageService.onDidSignIn(async () => {
167+
disposable.dispose();
168+
this.resumeEditSession(undefined, true);
169+
this.storageService.remove(EditSessionsContribution.APPLICATION_LAUNCHED_VIA_CONTINUE_ON_STORAGE_KEY, StorageScope.APPLICATION);
170+
this.environmentService.continueOn = undefined;
171+
});
172+
};
173+
163174
if ((this.environmentService.continueOn !== undefined) &&
164175
!this.editSessionsStorageService.isSignedIn &&
165176
// and user has not yet been prompted to sign in on this machine
@@ -170,17 +181,14 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
170181
if (this.editSessionsStorageService.isSignedIn) {
171182
await this.resumeEditSession(undefined, true);
172183
} else {
173-
this.updateAccountsMenuBadge();
184+
handlePendingEditSessions();
174185
}
175186
// store the fact that we prompted the user
176187
} else if (!this.editSessionsStorageService.isSignedIn &&
177188
// and user has been prompted to sign in on this machine
178189
hasApplicationLaunchedFromContinueOnFlow === true
179190
) {
180-
// display a badge in the accounts menu but do not prompt the user to sign in again
181-
this.updateAccountsMenuBadge();
182-
// attempt a resume if we are in a pending state and the user just signed in
183-
this._register(this.editSessionsStorageService.onDidSignIn(async () => this.resumeEditSession(undefined, true)));
191+
handlePendingEditSessions();
184192
}
185193
}
186194

0 commit comments

Comments
 (0)