Skip to content

Commit 4def400

Browse files
committed
Clean up
1 parent c1e4c39 commit 4def400

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
@@ -184,14 +184,11 @@ export class Commands {
184184
// It is possible that we are trying to log into an old-style host, in which
185185
// case we want to write with the provided blank label instead of generating
186186
// a host label.
187-
const label = args?.label === undefined ? toSafeHost(url) : args?.label;
187+
const label = args?.label === undefined ? toSafeHost(url) : args.label;
188188

189189
// Try to get a token from the user, if we need one, and their user.
190-
const res = await this.maybeAskToken(
191-
url,
192-
args?.token,
193-
args?.autoLogin === true,
194-
);
190+
const autoLogin = args?.autoLogin === true;
191+
const res = await this.maybeAskToken(url, args?.token, autoLogin);
195192
if (!res) {
196193
return; // The user aborted, or unable to auth.
197194
}

src/remote.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface RemoteDetails extends vscode.Disposable {
4444
}
4545

4646
export class Remote {
47+
// Used to race between the login dialog and the logging in from a different window
4748
private loginDetectedResolver: (() => void) | undefined;
4849
private loginDetectedPromise: Promise<void> = Promise.resolve();
4950

@@ -59,7 +60,6 @@ export class Remote {
5960

6061
/**
6162
* Creates a new promise that will be resolved when login is detected in another window.
62-
* This should be called when starting a setup operation that might need login.
6363
*/
6464
private createLoginDetectionPromise(): void {
6565
this.loginDetectedPromise = new Promise<void>((resolve) => {
@@ -69,7 +69,6 @@ export class Remote {
6969

7070
/**
7171
* Resolves the current login detection promise if one exists.
72-
* This should be called from the extension when login is detected.
7372
*/
7473
public resolveLoginDetected(): void {
7574
if (this.loginDetectedResolver) {
@@ -241,14 +240,13 @@ export class Remote {
241240
// Migrate "session_token" file to "session", if needed.
242241
await this.migrateSessionToken(parts.label);
243242

244-
// Try to detect any login event that might happen after we read the current configs
245-
this.createLoginDetectionPromise();
246243
// Get the URL and token belonging to this host.
247244
const { url: baseUrlRaw, token } = await this.cliManager.readConfig(
248245
parts.label,
249246
);
250247

251248
const showLoginDialog = async (message: string) => {
249+
this.createLoginDetectionPromise();
252250
const dialogPromise = this.vscodeProposed.window.showInformationMessage(
253251
message,
254252
{
@@ -359,8 +357,6 @@ export class Remote {
359357
// Next is to find the workspace from the URI scheme provided.
360358
let workspace: Workspace;
361359
try {
362-
// We could've logged out in the meantime
363-
this.createLoginDetectionPromise();
364360
this.logger.info(`Looking for workspace ${workspaceName}...`);
365361
workspace = await workspaceClient.getWorkspaceByOwnerAndName(
366362
parts.username,

0 commit comments

Comments
 (0)