Skip to content

Commit 122741f

Browse files
Merge pull request #1006 from gjsjohnmurray/fix-1005
Skip triggering refreshes at end of some checkConnection calls
2 parents bc300f9 + f0704a6 commit 122741f

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

src/api/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,11 @@ export class AtelierAPI {
343343
authRequestMap.delete(target);
344344
if (this.wsOrFile && !checkingConnection) {
345345
setTimeout(() => {
346-
checkConnection(password ? true : false, typeof this.wsOrFile === "object" ? this.wsOrFile : undefined);
346+
checkConnection(
347+
password ? true : false,
348+
typeof this.wsOrFile === "object" ? this.wsOrFile : undefined,
349+
true
350+
);
347351
}, 500);
348352
}
349353
throw { statusCode: response.status, message: response.statusText };
@@ -425,7 +429,7 @@ export class AtelierAPI {
425429
workspaceState.update(this.configName + ":host", undefined);
426430
workspaceState.update(this.configName + ":port", undefined);
427431
if (!checkingConnection) {
428-
setTimeout(checkConnection, 30000);
432+
setTimeout(() => checkConnection(false, undefined, true), 30000);
429433
}
430434
} else if (error.code === "EPROTO") {
431435
// This can happen if https was configured but didn't work

src/commands/serverActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export async function serverActions(): Promise<void> {
5353
return connConfig.update("conn", { ...targetConfig, active: !active }, target);
5454
}
5555
case "refreshConnection": {
56-
await checkConnection(true);
56+
await checkConnection(true, undefined, true);
5757
break;
5858
}
5959
default:

src/extension.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,11 @@ export function getResolvedConnectionSpec(key: string, dflt: any): any {
232232
*/
233233
export const cspApps: Map<string, string[]> = new Map();
234234

235-
export async function checkConnection(clearCookies = false, uri?: vscode.Uri): Promise<void> {
235+
export async function checkConnection(
236+
clearCookies = false,
237+
uri?: vscode.Uri,
238+
triggerRefreshes?: boolean
239+
): Promise<void> {
236240
// Do nothing if already checking the connection
237241
if (checkingConnection) {
238242
return;
@@ -419,16 +423,18 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
419423
})
420424
.finally(() => {
421425
checkingConnection = false;
422-
setTimeout(() => {
423-
explorerProvider.refresh();
424-
projectsExplorerProvider.refresh();
425-
// Refreshing Files Explorer also switches to it, so only do this if the uri is part of the workspace,
426-
// otherwise files opened from ObjectScript Explorer (objectscript:// or isfs:// depending on the "objectscript.serverSideEditing" setting)
427-
// will cause an unwanted switch.
428-
if (uri && schemas.includes(uri.scheme) && vscode.workspace.getWorkspaceFolder(uri)) {
429-
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
430-
}
431-
}, 20);
426+
if (triggerRefreshes) {
427+
setTimeout(() => {
428+
explorerProvider.refresh();
429+
projectsExplorerProvider.refresh();
430+
// Refreshing Files Explorer also switches to it, so only do this if the uri is part of the workspace,
431+
// otherwise files opened from ObjectScript Explorer (objectscript:// or isfs:// depending on the "objectscript.serverSideEditing" setting)
432+
// will cause an unwanted switch.
433+
if (uri && schemas.includes(uri.scheme) && vscode.workspace.getWorkspaceFolder(uri)) {
434+
vscode.commands.executeCommand("workbench.files.action.refreshFilesExplorer");
435+
}
436+
}, 20);
437+
}
432438
});
433439
}
434440

@@ -601,7 +607,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
601607
try {
602608
await resolveConnectionSpec(serverName);
603609
} finally {
604-
await checkConnection(true, uri);
610+
await checkConnection(true, uri, true);
605611
}
606612
} catch (_) {
607613
// Ignore any failure
@@ -1067,7 +1073,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10671073
refreshFilesExplorer = true;
10681074
}
10691075
try {
1070-
await checkConnection(true, folder.uri);
1076+
await checkConnection(true, folder.uri, true);
10711077
} catch (_) {
10721078
continue;
10731079
}

0 commit comments

Comments
 (0)