@@ -89,14 +89,7 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
89
89
this . setState ( { startedInstanceId : result . instanceID } ) ;
90
90
// Explicitly query state to guarantee we get at least one update
91
91
// (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 ( ) ;
100
93
} catch ( error ) {
101
94
console . error ( error ) ;
102
95
if ( typeof error === 'string' ) {
@@ -106,6 +99,26 @@ export default class StartWorkspace extends React.Component<StartWorkspaceProps,
106
99
}
107
100
}
108
101
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
+
109
122
async onInstanceUpdate ( workspaceInstance : WorkspaceInstance ) {
110
123
const startedInstanceId = this . state ?. startedInstanceId ;
111
124
if ( workspaceInstance . workspaceId !== this . props . workspaceId || startedInstanceId !== workspaceInstance . id ) {
0 commit comments