Skip to content

Commit

Permalink
Re-organise disconnected state
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Dec 3, 2024
1 parent d6dd187 commit a69402b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/api/IBMi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,8 @@ export default class IBMi {
this.client.connection?.removeAllListeners();
this.client.dispose();
this.client.connection = null;

instance.fire(`disconnected`);
}
}

Expand All @@ -1254,8 +1256,6 @@ export default class IBMi {
if (this.outputChannelContent !== undefined) {
this.outputChannelContent = undefined;
}

instance.fire(`disconnected`);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/api/Instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class Instance {
});
}

await conn.dispose();
this.setConnection();

if (reconnect) {
await this.connect({...options, reconnecting: true});
Expand All @@ -75,7 +75,7 @@ export default class Instance {
break;

} else {
await this.setConnection();
await this.disconnect();
if (options.reconnecting && await vscode.window.showWarningMessage(`Could not reconnect`, {
modal: true,
detail: `Reconnection has failed. Would you like to try again?\n\n${result.error || `No error provided.`}`
Expand Down Expand Up @@ -110,11 +110,11 @@ export default class Instance {
}

private async setConnection(connection?: IBMi) {
if (connection) {
if (this.connection) {
await this.connection.dispose();
}
if (this.connection) {
await this.connection.dispose();
}

if (connection) {
this.connection = connection;
this.storage.setConnectionName(connection.currentConnectionName);
await GlobalStorage.get().setLastConnection(connection.currentConnectionName);
Expand Down

0 comments on commit a69402b

Please sign in to comment.