-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propagate and handle connection/disconnection events #1142
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ec59980
Only show connection dependent command when connected
sebjulliand a9ff448
Handle disconnection propagation
sebjulliand 5c39887
Update index.js
sebjulliand 26e1dfa
Missing handle on handler's edit timeout
sebjulliand f224e9b
Fixed source dates not showing up
sebjulliand 46b21ae
Handle source date settings change for active editors
sebjulliand ca82003
Moved "set connected" context value to IBMi
sebjulliand 9d6dd25
Load views on connected event
sebjulliand f32c80d
Removed force reconnect and always show disconnect
sebjulliand 61ecc51
Force synch refresh of views on disconnect to empty them
sebjulliand ad336f6
Don't let Instance share its toys
sebjulliand 2cc03b5
Fixed source dates not showing when opened/changed
sebjulliand 717d0e7
Moved and updated disconnection message
sebjulliand a03edd8
Clear instance's connection on disconnection
sebjulliand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,66 @@ | ||
import * as vscode from "vscode"; | ||
import IBMi from "./IBMi"; | ||
import IBMiContent from "./IBMiContent"; | ||
import {ConnectionStorage} from "./Storage"; | ||
import { ConnectionStorage, GlobalStorage } from "./Storage"; | ||
import { ConnectionConfiguration } from "./Configuration"; | ||
import { IBMiEvent } from "../typings"; | ||
|
||
export default class Instance { | ||
connection: IBMi|undefined; | ||
content: IBMiContent|undefined; | ||
storage: ConnectionStorage|undefined; | ||
emitter: vscode.EventEmitter<any>|undefined; | ||
events: {event: string, func: Function}[]; | ||
|
||
constructor() { | ||
this.events = []; | ||
} | ||
|
||
getConnection() { | ||
return this.connection; | ||
} | ||
private connection: IBMi | undefined; | ||
private content: IBMiContent | undefined; | ||
private storage: ConnectionStorage; | ||
private emitter: vscode.EventEmitter<IBMiEvent> = new vscode.EventEmitter(); | ||
private events: { event: IBMiEvent, func: Function }[] = []; | ||
|
||
async setConfig(newConfig: ConnectionConfiguration.Parameters) { | ||
await ConnectionConfiguration.update(newConfig); | ||
if (this.connection) this.connection.config = newConfig; | ||
} | ||
getConfig() { | ||
return this.connection?.config; | ||
} | ||
getContent () { | ||
return this.content; | ||
constructor(context: vscode.ExtensionContext) { | ||
this.events = []; | ||
this.storage = new ConnectionStorage(context); | ||
this.emitter.event(e => { | ||
this.events.filter(event => event.event === e) | ||
.forEach(event => event.func()); | ||
}) | ||
} | ||
|
||
async setConnection(connection?: IBMi) { | ||
if (connection) { | ||
this.connection = connection; | ||
this.storage.setConnectionName(connection.currentConnectionName); | ||
this.content = new IBMiContent(connection); | ||
await GlobalStorage.get().setLastConnection(connection.currentConnectionName); | ||
} | ||
getStorage () { | ||
return this.storage; | ||
else { | ||
this.connection = undefined; | ||
this.content = undefined; | ||
this.storage.setConnectionName(""); | ||
} | ||
} | ||
|
||
onEvent(event: "connected" | "disconnected" | "deployLocation", func: Function): void { | ||
this.events.push({event, func}); | ||
} | ||
}; | ||
getConnection() { | ||
return this.connection; | ||
} | ||
|
||
async setConfig(newConfig: ConnectionConfiguration.Parameters) { | ||
await ConnectionConfiguration.update(newConfig); | ||
if (this.connection) this.connection.config = newConfig; | ||
} | ||
|
||
getConfig() { | ||
return this.connection?.config; | ||
} | ||
|
||
getContent() { | ||
return this.content; | ||
} | ||
|
||
getStorage() { | ||
return this.storage.ready ? this.storage : undefined; | ||
} | ||
|
||
onEvent(event: IBMiEvent, func: Function): void { | ||
this.events.push({ event, func }); | ||
} | ||
|
||
fire(event: IBMiEvent) { | ||
this.emitter?.fire(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is welcome change. Fingers crossed anyone using our extension API isn't using these!