@@ -101,17 +101,21 @@ const toStop = new DisposableCollection();
101
101
window . addEventListener ( 'message' , hideDesktopIdeEventListener , false ) ;
102
102
toStop . push ( { dispose : ( ) => window . removeEventListener ( 'message' , hideDesktopIdeEventListener ) } ) ;
103
103
104
+ let isDesktopIde : undefined | boolean = undefined ;
105
+ let ideStatus : undefined | { desktop : { link : string , label : string } } = undefined ;
106
+
104
107
//#region current-frame
105
108
let current : HTMLElement = loading . frame ;
106
109
let stopped = false ;
107
- const nextFrame = async ( ) => {
110
+ const nextFrame = ( ) => {
108
111
const instance = gitpodServiceClient . info . latestInstance ;
109
112
if ( instance ) {
110
113
if ( instance . status . phase === 'running' ) {
111
114
if ( ! hideDesktopIde ) {
112
- const ideStatus = await supervisorServiceClient . ideReady ;
113
- const isDesktopIde = ideStatus && ideStatus . desktop && ideStatus . desktop . link ;
114
- if ( isDesktopIde ) {
115
+ if ( isDesktopIde == undefined ) {
116
+ return loading . frame ;
117
+ }
118
+ if ( isDesktopIde && ! ! ideStatus ) {
115
119
loading . setState ( {
116
120
desktopIdeLink : ideStatus . desktop . link ,
117
121
desktopIdeLabel : ideStatus . desktop . label || "Open Desktop IDE"
@@ -140,8 +144,8 @@ const toStop = new DisposableCollection();
140
144
}
141
145
return loading . frame ;
142
146
}
143
- const updateCurrentFrame = async ( ) => {
144
- const newCurrent = await nextFrame ( ) ;
147
+ const updateCurrentFrame = ( ) => {
148
+ const newCurrent = nextFrame ( ) ;
145
149
if ( current === newCurrent ) {
146
150
return ;
147
151
}
@@ -184,7 +188,7 @@ const toStop = new DisposableCollection();
184
188
trackStatusRenderedEvent ( `ide-${ ideService . state } ` , error ) ;
185
189
}
186
190
187
- await updateCurrentFrame ( ) ;
191
+ updateCurrentFrame ( ) ;
188
192
updateLoadingState ( ) ;
189
193
trackIDEStatusRenderedEvent ( ) ;
190
194
gitpodServiceClient . onDidChangeInfo ( ( ) => updateCurrentFrame ( ) ) ;
@@ -193,6 +197,11 @@ const toStop = new DisposableCollection();
193
197
updateCurrentFrame ( ) ;
194
198
trackIDEStatusRenderedEvent ( ) ;
195
199
} ) ;
200
+ supervisorServiceClient . ideReady . then ( newIdeStatus => {
201
+ ideStatus = newIdeStatus ;
202
+ isDesktopIde = ! ! ideStatus && ! ! ideStatus . desktop && ! ! ideStatus . desktop . link ;
203
+ updateCurrentFrame ( ) ;
204
+ } ) . catch ( error => console . error ( `Unexpected error from supervisorServiceClient.ideReady: ${ error } ` ) ) ;
196
205
window . addEventListener ( 'unload' , ( ) => trackStatusRenderedEvent ( 'window-unload' ) , { capture : true } ) ;
197
206
//#endregion
198
207
0 commit comments