Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Update project object on projectCreation event (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Etchells authored Oct 18, 2019
1 parent 3b15891 commit 569face
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 11 additions & 4 deletions dev/src/codewind/connection/MCSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ export default class MCSocket implements vscode.Disposable {
.on("connect", this.connection.onConnect) // non-nls
.on("disconnect", this.connection.onDisconnect) // non-nls

// .on(SocketEvents.Types.PROJECT_CREATED, this.onProjectCreated)
.on(SocketEvents.Types.PROJECT_BOUND, this.onProjectCreated)
.on(SocketEvents.Types.PROJECT_BOUND, this.onProjectBound)

.on(SocketEvents.Types.PROJECT_CREATED, this.onProjectCreation)
.on(SocketEvents.Types.PROJECT_CHANGED, this.onProjectChanged)
.on(SocketEvents.Types.PROJECT_STATUS_CHANGED, this.onProjectStatusChanged)
.on(SocketEvents.Types.PROJECT_CLOSED, this.onProjectClosed)
Expand All @@ -91,7 +92,7 @@ export default class MCSocket implements vscode.Disposable {
this.socket.disconnect();
}

private readonly onProjectCreated = async (payload: { success: boolean; projectID?: string; error?: string; }): Promise<void> => {
private readonly onProjectBound = async (payload: { success: boolean; projectID?: string; error?: string; }): Promise<void> => {
await this.connection.forceUpdateProjectList();

if (payload.projectID) {
Expand Down Expand Up @@ -120,9 +121,15 @@ export default class MCSocket implements vscode.Disposable {
}
}

private readonly onProjectCreation = async (payload: any): Promise<void> => {
// https://github.com/eclipse/codewind/issues/720#issuecomment-543801321
// creation event is now, apparently, the same as changed event
this.onProjectChanged(payload);
}

private readonly onProjectStatusChanged = async (payload: { projectID: string }): Promise<void> => {
// Log.d("onProjectStatusChanged", payload);
// I don't see any reason why these should be handled differently
// portal emits the entire inf file with a statusChanged event, so we can treat this the same as projectChanged
this.onProjectChanged(payload);
}

Expand Down
6 changes: 4 additions & 2 deletions dev/src/codewind/project/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class Project implements vscode.QuickPickItem {
}

const ports = projectInfo.ports;
if (ports != null) {
if (ports) {
this.updatePorts(ports);
}
else if (this._state.isStarted) {
Expand Down Expand Up @@ -596,8 +596,10 @@ export default class Project implements vscode.QuickPickItem {
}
else if (currentPort !== newPortNumber) {
if (isNaN(newPortNumber)) {
if (this._ports[portType]) {
Log.d(`Unset ${portType} for ${this.name}`);
}
this._ports[portType] = undefined;
// Log.d(`Unset ${portType} for ${this.name}`);
}
else if (newPortNumber !== currentPort) {
Log.d(`New ${portType} for ${this.name} is ${newPortNumber}`);
Expand Down

0 comments on commit 569face

Please sign in to comment.