From 2b17f0dc16688538d88c6c5565c4cbaf93979b60 Mon Sep 17 00:00:00 2001 From: Jean Pierre Date: Tue, 17 Jan 2023 18:11:06 +0000 Subject: [PATCH] [Fix] Send initial status --- components/dashboard/src/service/service.tsx | 22 ++++++++------------ 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/components/dashboard/src/service/service.tsx b/components/dashboard/src/service/service.tsx index cbb640ae23cac7..ccae3c6c4c58cf 100644 --- a/components/dashboard/src/service/service.tsx +++ b/components/dashboard/src/service/service.tsx @@ -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 {