Skip to content

Commit

Permalink
[dashboard] Make Start page re-fetch workspace info after a connectio…
Browse files Browse the repository at this point in the history
…n drop

Fixes #3811
  • Loading branch information
jankeromnes committed Apr 9, 2021
1 parent d114f03 commit 1d3f7a1
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
this.setState({ startedInstanceId: result.instanceID });
// Explicitly query state to guarantee we get at least one update
// (needed for already started workspaces, and not hanging in 'Starting ...' for too long)
getGitpodService().server.getWorkspace(workspaceId).then(ws => {
if (ws.latestInstance) {
this.setState({
workspace: ws.workspace
});
this.onInstanceUpdate(ws.latestInstance);
}
});
this.fetchWorkspaceInfo();
} catch (error) {
console.error(error);
if (typeof error === 'string') {
Expand All @@ -106,6 +99,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
}
}

async fetchWorkspaceInfo() {
const { workspaceId } = this.props;
try {
const info = await getGitpodService().server.getWorkspace(workspaceId);
if (info.latestInstance) {
this.setState({
workspace: info.workspace
});
this.onInstanceUpdate(info.latestInstance);
}
} catch (error) {
console.error(error);
this.setState({ error });
}
}

notifyDidOpenConnection() {
this.fetchWorkspaceInfo();
}

async onInstanceUpdate(workspaceInstance: WorkspaceInstance) {
const startedInstanceId = this.state?.startedInstanceId;
if (workspaceInstance.workspaceId !== this.props.workspaceId || startedInstanceId !== workspaceInstance.id) {
Expand Down

0 comments on commit 1d3f7a1

Please sign in to comment.