Skip to content

Commit 1d3f7a1

Browse files
committed
[dashboard] Make Start page re-fetch workspace info after a connection drop
Fixes #3811
1 parent d114f03 commit 1d3f7a1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
8989
this.setState({ startedInstanceId: result.instanceID });
9090
// Explicitly query state to guarantee we get at least one update
9191
// (needed for already started workspaces, and not hanging in 'Starting ...' for too long)
92-
getGitpodService().server.getWorkspace(workspaceId).then(ws => {
93-
if (ws.latestInstance) {
94-
this.setState({
95-
workspace: ws.workspace
96-
});
97-
this.onInstanceUpdate(ws.latestInstance);
98-
}
99-
});
92+
this.fetchWorkspaceInfo();
10093
} catch (error) {
10194
console.error(error);
10295
if (typeof error === 'string') {
@@ -106,6 +99,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
10699
}
107100
}
108101

102+
async fetchWorkspaceInfo() {
103+
const { workspaceId } = this.props;
104+
try {
105+
const info = await getGitpodService().server.getWorkspace(workspaceId);
106+
if (info.latestInstance) {
107+
this.setState({
108+
workspace: info.workspace
109+
});
110+
this.onInstanceUpdate(info.latestInstance);
111+
}
112+
} catch (error) {
113+
console.error(error);
114+
this.setState({ error });
115+
}
116+
}
117+
118+
notifyDidOpenConnection() {
119+
this.fetchWorkspaceInfo();
120+
}
121+
109122
async onInstanceUpdate(workspaceInstance: WorkspaceInstance) {
110123
const startedInstanceId = this.state?.startedInstanceId;
111124
if (workspaceInstance.workspaceId !== this.props.workspaceId || startedInstanceId !== workspaceInstance.id) {

0 commit comments

Comments
 (0)