Skip to content

Commit 5b12905

Browse files
committed
event onDidChangeConnection, fired when port or password changed
1 parent 3fc05c9 commit 5b12905

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ const packageJson = vscode.extensions.getExtension(extensionId).packageJSON;
9999
const extensionVersion = packageJson.version;
100100
const aiKey = packageJson.aiKey;
101101

102+
const _onDidChangeConnection = new vscode.EventEmitter<void>();
103+
102104
export const config = (setting?: string, workspaceFolderName?: string): vscode.WorkspaceConfiguration | any => {
103105
workspaceFolderName = workspaceFolderName || currentWorkspaceFolder();
104106
if (
@@ -192,6 +194,7 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
192194
workspaceState.update(configName + ":password", undefined);
193195
workspaceState.update(configName + ":apiVersion", undefined);
194196
workspaceState.update(configName + ":docker", undefined);
197+
_onDidChangeConnection.fire();
195198
}
196199
let api = new AtelierAPI(apiTarget, false);
197200
const { active, host = "", port = 0, ns = "" } = api.config;
@@ -224,6 +227,7 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
224227
workspaceState.update(configName + ":port", dockerPort);
225228
}
226229
connInfo = `localhost:${dockerPort}[${ns}]`;
230+
_onDidChangeConnection.fire();
227231
}
228232
} catch (error) {
229233
outputChannel.appendError(error);
@@ -279,6 +283,7 @@ export async function checkConnection(clearCookies = false, uri?: vscode.Uri): P
279283
async (password) => {
280284
if (password) {
281285
workspaceState.update(configName + ":password", password);
286+
_onDidChangeConnection.fire();
282287
await checkConnection(false, uri);
283288
} else if (!api.externalServer) {
284289
disableConnection(configName);
@@ -823,6 +828,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
823828
}
824829
return uri;
825830
},
831+
onDidChangeConnection(): vscode.Event<void> {
832+
return _onDidChangeConnection.event;
833+
},
826834
};
827835

828836
// 'export' our public API

0 commit comments

Comments
 (0)