Skip to content

Commit edb505c

Browse files
committed
Clean up
1 parent df63df6 commit edb505c

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

src/commands.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,11 @@ export class Commands {
197197
// It is possible that we are trying to log into an old-style host, in which
198198
// case we want to write with the provided blank label instead of generating
199199
// a host label.
200-
const label = args?.label === undefined ? toSafeHost(url) : args?.label;
200+
const label = args?.label === undefined ? toSafeHost(url) : args.label;
201201

202202
// Try to get a token from the user, if we need one, and their user.
203-
const res = await this.maybeAskToken(
204-
url,
205-
args?.token,
206-
args?.autoLogin === true,
207-
);
203+
const autoLogin = args?.autoLogin === true;
204+
const res = await this.maybeAskToken(url, args?.token, autoLogin);
208205
if (!res) {
209206
return; // The user aborted, or unable to auth.
210207
}

src/remote/remote.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class Remote {
5959
private readonly pathResolver: PathResolver;
6060
private readonly cliManager: CliManager;
6161

62+
// Used to race between the login dialog and the logging in from a different window
6263
private loginDetectedResolver: (() => void) | undefined;
6364
private loginDetectedPromise: Promise<void> = Promise.resolve();
6465

@@ -75,7 +76,6 @@ export class Remote {
7576

7677
/**
7778
* Creates a new promise that will be resolved when login is detected in another window.
78-
* This should be called when starting a setup operation that might need login.
7979
*/
8080
private createLoginDetectionPromise(): void {
8181
this.loginDetectedPromise = new Promise<void>((resolve) => {
@@ -85,7 +85,6 @@ export class Remote {
8585

8686
/**
8787
* Resolves the current login detection promise if one exists.
88-
* This should be called from the extension when login is detected.
8988
*/
9089
public resolveLoginDetected(): void {
9190
if (this.loginDetectedResolver) {
@@ -257,14 +256,13 @@ export class Remote {
257256
// Migrate "session_token" file to "session", if needed.
258257
await this.migrateSessionToken(parts.label);
259258

260-
// Try to detect any login event that might happen after we read the current configs
261-
this.createLoginDetectionPromise();
262259
// Get the URL and token belonging to this host.
263260
const { url: baseUrlRaw, token } = await this.cliManager.readConfig(
264261
parts.label,
265262
);
266263

267264
const showLoginDialog = async (message: string) => {
265+
this.createLoginDetectionPromise();
268266
const dialogPromise = this.vscodeProposed.window.showInformationMessage(
269267
message,
270268
{
@@ -370,8 +368,6 @@ export class Remote {
370368
// Next is to find the workspace from the URI scheme provided.
371369
let workspace: Workspace;
372370
try {
373-
// We could've logged out in the meantime
374-
this.createLoginDetectionPromise();
375371
this.logger.info(`Looking for workspace ${workspaceName}...`);
376372
workspace = await workspaceClient.getWorkspaceByOwnerAndName(
377373
parts.username,

0 commit comments

Comments
 (0)