Skip to content

Commit

Permalink
[Fix] Send initial status
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanp413 authored and roboquat committed Jan 18, 2023
1 parent 9940061 commit 2b17f0d
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions components/dashboard/src/service/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,21 @@ export class IDEFrontendService implements IDEFrontendDashboardService.IServer {

private async processServerInfo() {
this.user = await this.service.server.getLoggedInUser();
const workspace = await this.service.server.getWorkspace(this.workspaceID);
this.instanceID = workspace.latestInstance?.id;
if (this.instanceID) {
this.auth();
}

const listener = await this.service.listenToInstance(this.workspaceID);
listener.onDidChange(() => {
this.ideUrl = listener.info.latestInstance?.ideUrl
? new URL(listener.info.latestInstance?.ideUrl)
: undefined;
const reconcile = () => {
const status = this.getWorkspaceStatus(listener.info);
this.latestStatus = status;
this.sendStatusUpdate(this.latestStatus);
if (this.instanceID !== status.instanceId) {
this.instanceID = status.instanceId;
this.ideUrl = status.ideUrl ? new URL(status.ideUrl) : undefined;
const oldInstanceID = this.instanceID;
this.instanceID = status.instanceId;
if (status.instanceId && oldInstanceID !== status.instanceId) {
this.auth();
}
});
this.sendStatusUpdate(this.latestStatus);
};
reconcile();
listener.onDidChange(reconcile);
}

getWorkspaceStatus(workspace: WorkspaceInfo): IDEFrontendDashboardService.Status {
Expand Down

0 comments on commit 2b17f0d

Please sign in to comment.