@@ -29,7 +29,6 @@ import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configur
29
29
import { ContextKeyExpr , ContextKeyExpression , IContextKeyService , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
30
30
import { IRecentFolder , IRecentlyOpened , IRecentWorkspace , isRecentFolder , isRecentWorkspace , IWorkspacesService } from 'vs/platform/workspaces/common/workspaces' ;
31
31
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
32
- import { onUnexpectedError } from 'vs/base/common/errors' ;
33
32
import { ILabelService , Verbosity } from 'vs/platform/label/common/label' ;
34
33
import { IWindowOpenable } from 'vs/platform/window/common/window' ;
35
34
import { splitName } from 'vs/base/common/labels' ;
@@ -74,6 +73,7 @@ import { IFeaturedExtensionsService } from 'vs/workbench/contrib/welcomeGettingS
74
73
import { IFeaturedExtension } from 'vs/base/common/product' ;
75
74
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement' ;
76
75
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
76
+ import { ILifecycleService , LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle' ;
77
77
78
78
const SLIDE_TRANSITION_TIME_MS = 250 ;
79
79
const configurationKey = 'workbench.startupEditor' ;
@@ -129,8 +129,11 @@ export class GettingStartedPage extends EditorPane {
129
129
private stepDisposables : DisposableStore = new DisposableStore ( ) ;
130
130
private detailsPageDisposables : DisposableStore = new DisposableStore ( ) ;
131
131
132
- private gettingStartedCategories : IResolvedWalkthrough [ ] ;
133
- private featuredExtensions ?: Promise < IFeaturedExtension [ ] > ;
132
+ // Ensure that the these are initialized before use.
133
+ // Currently initialized before use in buildCategoriesSlide and scrollToCategory
134
+ private recentlyOpened ! : IRecentlyOpened ;
135
+ private gettingStartedCategories ! : IResolvedWalkthrough [ ] ;
136
+ private featuredExtensions ! : IFeaturedExtension [ ] ;
134
137
135
138
private currentWalkthrough : IResolvedWalkthrough | undefined ;
136
139
@@ -145,7 +148,6 @@ export class GettingStartedPage extends EditorPane {
145
148
146
149
private contextService : IContextKeyService ;
147
150
148
- private recentlyOpened : Promise < IRecentlyOpened > ;
149
151
private hasScrolledToFirstCategory = false ;
150
152
private recentlyOpenedList ?: GettingStartedIndexList < RecentEntry > ;
151
153
private startList ?: GettingStartedIndexList < IWelcomePageStartEntry > ;
@@ -182,13 +184,14 @@ export class GettingStartedPage extends EditorPane {
182
184
@IEditorGroupsService private readonly groupsService : IEditorGroupsService ,
183
185
@IContextKeyService contextService : IContextKeyService ,
184
186
@IQuickInputService private quickInputService : IQuickInputService ,
185
- @IWorkspacesService workspacesService : IWorkspacesService ,
187
+ @IWorkspacesService private readonly workspacesService : IWorkspacesService ,
186
188
@ILabelService private readonly labelService : ILabelService ,
187
189
@IHostService private readonly hostService : IHostService ,
188
190
@IWebviewService private readonly webviewService : IWebviewService ,
189
191
@IWorkspaceContextService private readonly workspaceContextService : IWorkspaceContextService ,
190
192
@IAccessibilityService private readonly accessibilityService : IAccessibilityService ,
191
- @IExtensionManagementService private readonly extensionManagementService : IExtensionManagementService
193
+ @IExtensionManagementService private readonly extensionManagementService : IExtensionManagementService ,
194
+ @ILifecycleService private readonly lifecycleService : ILifecycleService ,
192
195
) {
193
196
194
197
super ( GettingStartedPage . ID , telemetryService , themeService , storageService ) ;
@@ -209,28 +212,11 @@ export class GettingStartedPage extends EditorPane {
209
212
this . contextService = this . _register ( contextService . createScoped ( this . container ) ) ;
210
213
inWelcomeContext . bindTo ( this . contextService ) . set ( true ) ;
211
214
212
- this . gettingStartedCategories = this . gettingStartedService . getWalkthroughs ( ) ;
213
- this . featuredExtensions = this . featuredExtensionService . getExtensions ( ) ;
214
-
215
215
this . _register ( this . dispatchListeners ) ;
216
216
this . buildSlideThrottle = new Throttler ( ) ;
217
217
218
218
const rerender = ( ) => {
219
- this . gettingStartedCategories = this . gettingStartedService . getWalkthroughs ( ) ;
220
- this . featuredExtensions = this . featuredExtensionService . getExtensions ( ) ;
221
-
222
- if ( this . currentWalkthrough ) {
223
- const existingSteps = this . currentWalkthrough . steps . map ( step => step . id ) ;
224
- const newCategory = this . gettingStartedCategories . find ( category => this . currentWalkthrough ?. id === category . id ) ;
225
- if ( newCategory ) {
226
- const newSteps = newCategory . steps . map ( step => step . id ) ;
227
- if ( ! equals ( newSteps , existingSteps ) ) {
228
- this . buildSlideThrottle . queue ( ( ) => this . buildCategoriesSlide ( ) ) ;
229
- }
230
- }
231
- } else {
232
- this . buildSlideThrottle . queue ( ( ) => this . buildCategoriesSlide ( ) ) ;
233
- }
219
+ this . buildSlideThrottle . queue ( async ( ) => await this . buildCategoriesSlide ( ) ) ;
234
220
} ;
235
221
236
222
this . _register ( this . extensionManagementService . onDidInstallExtensions ( async ( result ) => {
@@ -242,30 +228,9 @@ export class GettingStartedPage extends EditorPane {
242
228
}
243
229
} ) ) ;
244
230
245
- this . _register ( this . gettingStartedService . onDidAddBuiltInWalkthrough ( ( ) => {
246
- rerender ( ) ;
247
- const someStepsComplete = this . gettingStartedCategories . some ( category => category . steps . find ( s => s . done ) ) ;
248
- if ( ! this . productService . openToWelcomeMainPage && ! someStepsComplete && ! this . hasScrolledToFirstCategory ) {
249
- const firstSessionDateString = this . storageService . get ( firstSessionDateStorageKey , StorageScope . APPLICATION ) || new Date ( ) . toUTCString ( ) ;
250
- const daysSinceFirstSession = ( ( + new Date ( ) ) - ( + new Date ( firstSessionDateString ) ) ) / 1000 / 60 / 60 / 24 ;
251
- const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index' ;
252
-
253
- if ( fistContentBehaviour === 'openToFirstCategory' ) {
254
- const first = this . gettingStartedCategories . filter ( c => ! c . when || this . contextService . contextMatchesRules ( c . when ) ) [ 0 ] ;
255
- this . hasScrolledToFirstCategory = true ;
256
- if ( first ) {
257
- this . currentWalkthrough = first ;
258
- this . editorInput . selectedCategory = this . currentWalkthrough ?. id ;
259
- this . buildCategorySlide ( this . editorInput . selectedCategory , undefined ) ;
260
- this . setSlide ( 'details' ) ;
261
- return ;
262
- }
263
- }
264
- }
265
- } ) ) ;
266
-
267
231
this . _register ( this . gettingStartedService . onDidAddWalkthrough ( rerender ) ) ;
268
232
this . _register ( this . gettingStartedService . onDidRemoveWalkthrough ( rerender ) ) ;
233
+ this . _register ( workspacesService . onDidChangeRecentlyOpened ( rerender ) ) ;
269
234
270
235
this . _register ( this . gettingStartedService . onDidChangeWalkthrough ( category => {
271
236
const ourCategory = this . gettingStartedCategories . find ( c => c . id === category . id ) ;
@@ -315,12 +280,6 @@ export class GettingStartedPage extends EditorPane {
315
280
}
316
281
this . updateCategoryProgress ( ) ;
317
282
} ) ) ;
318
-
319
- this . recentlyOpened = workspacesService . getRecentlyOpened ( ) ;
320
- this . _register ( workspacesService . onDidChangeRecentlyOpened ( ( ) => {
321
- this . recentlyOpened = workspacesService . getRecentlyOpened ( ) ;
322
- rerender ( ) ;
323
- } ) ) ;
324
283
}
325
284
326
285
// remove when 'workbench.welcomePage.preferReducedMotion' deprecated
@@ -345,6 +304,7 @@ export class GettingStartedPage extends EditorPane {
345
304
override async setInput ( newInput : GettingStartedInput , options : IEditorOptions | undefined , context : IEditorOpenContext , token : CancellationToken ) {
346
305
this . container . classList . remove ( 'animatable' ) ;
347
306
this . editorInput = newInput ;
307
+ await this . lifecycleService . when ( LifecyclePhase . Restored ) ;
348
308
await super . setInput ( newInput , options , context , token ) ;
349
309
await this . buildCategoriesSlide ( ) ;
350
310
if ( this . shouldAnimate ( ) ) {
@@ -353,16 +313,6 @@ export class GettingStartedPage extends EditorPane {
353
313
}
354
314
355
315
async makeCategoryVisibleWhenAvailable ( categoryID : string , stepId ?: string ) {
356
- if ( ! this . gettingStartedCategories . some ( c => c . id === categoryID ) ) {
357
- await this . gettingStartedService . installedExtensionsRegistered ;
358
- this . gettingStartedCategories = this . gettingStartedService . getWalkthroughs ( ) ;
359
- }
360
-
361
- const ourCategory = this . gettingStartedCategories . find ( c => c . id === categoryID ) ;
362
- if ( ! ourCategory ) {
363
- throw Error ( 'Could not find category with ID: ' + categoryID ) ;
364
- }
365
-
366
316
this . scrollToCategory ( categoryID , stepId ) ;
367
317
}
368
318
@@ -419,12 +369,8 @@ export class GettingStartedPage extends EditorPane {
419
369
break ;
420
370
}
421
371
case 'selectCategory' : {
422
- const selectedCategory = this . gettingStartedCategories . find ( category => category . id === argument ) ;
423
- if ( ! selectedCategory ) { throw Error ( 'Could not find category with ID ' + argument ) ; }
424
-
425
- this . gettingStartedService . markWalkthroughOpened ( argument ) ;
426
- this . gettingStartedList ?. setEntries ( this . gettingStartedService . getWalkthroughs ( ) ) ;
427
372
this . scrollToCategory ( argument ) ;
373
+ this . gettingStartedService . markWalkthroughOpened ( argument ) ;
428
374
break ;
429
375
}
430
376
case 'selectStartEntry' : {
@@ -717,8 +663,6 @@ export class GettingStartedPage extends EditorPane {
717
663
}
718
664
719
665
private async selectStep ( id : string | undefined , delayFocus = true ) {
720
- if ( id && this . editorInput . selectedStep === id ) { return ; }
721
-
722
666
if ( id ) {
723
667
let stepElement = this . container . querySelector < HTMLDivElement > ( `[data-step-id="${ id } "]` ) ;
724
668
if ( ! stepElement ) {
@@ -784,6 +728,11 @@ export class GettingStartedPage extends EditorPane {
784
728
}
785
729
786
730
private async buildCategoriesSlide ( ) {
731
+
732
+ this . recentlyOpened = await this . workspacesService . getRecentlyOpened ( ) ;
733
+ this . gettingStartedCategories = await this . gettingStartedService . getWalkthroughs ( ) ;
734
+ this . featuredExtensions = await this . featuredExtensionService . getExtensions ( ) ;
735
+
787
736
this . categoriesSlideDisposables . clear ( ) ;
788
737
const showOnStartupCheckbox = new Toggle ( {
789
738
icon : Codicon . check ,
@@ -883,10 +832,6 @@ export class GettingStartedPage extends EditorPane {
883
832
this . currentWalkthrough = this . gettingStartedCategories . find ( category => category . id === this . editorInput . selectedCategory ) ;
884
833
885
834
if ( ! this . currentWalkthrough ) {
886
- this . container . classList . add ( 'loading' ) ;
887
- await this . gettingStartedService . installedExtensionsRegistered ;
888
- this . container . classList . remove ( 'loading' ) ;
889
- this . gettingStartedCategories = this . gettingStartedService . getWalkthroughs ( ) ;
890
835
this . currentWalkthrough = this . gettingStartedCategories . find ( category => category . id === this . editorInput . selectedCategory ) ;
891
836
}
892
837
@@ -895,17 +840,35 @@ export class GettingStartedPage extends EditorPane {
895
840
this . editorInput . selectedCategory = undefined ;
896
841
this . editorInput . selectedStep = undefined ;
897
842
} else {
898
- this . buildCategorySlide ( this . editorInput . selectedCategory , this . editorInput . selectedStep ) ;
843
+ await this . buildCategorySlide ( this . editorInput . selectedCategory , this . editorInput . selectedStep ) ;
899
844
this . setSlide ( 'details' ) ;
900
845
return ;
901
846
}
902
847
}
903
848
849
+ const someStepsComplete = this . gettingStartedCategories . some ( category => category . steps . find ( s => s . done ) ) ;
904
850
if ( this . editorInput . showTelemetryNotice && this . productService . openToWelcomeMainPage ) {
905
851
const telemetryNotice = $ ( 'p.telemetry-notice' ) ;
906
852
this . buildTelemetryFooter ( telemetryNotice ) ;
907
853
footer . appendChild ( telemetryNotice ) ;
854
+ } else if ( ! this . productService . openToWelcomeMainPage && ! someStepsComplete && ! this . hasScrolledToFirstCategory ) {
855
+ const firstSessionDateString = this . storageService . get ( firstSessionDateStorageKey , StorageScope . APPLICATION ) || new Date ( ) . toUTCString ( ) ;
856
+ const daysSinceFirstSession = ( ( + new Date ( ) ) - ( + new Date ( firstSessionDateString ) ) ) / 1000 / 60 / 60 / 24 ;
857
+ const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index' ;
858
+
859
+ if ( fistContentBehaviour === 'openToFirstCategory' ) {
860
+ const first = this . gettingStartedCategories . filter ( c => ! c . when || this . contextService . contextMatchesRules ( c . when ) ) [ 0 ] ;
861
+ this . hasScrolledToFirstCategory = true ;
862
+ if ( first ) {
863
+ this . currentWalkthrough = first ;
864
+ this . editorInput . selectedCategory = this . currentWalkthrough ?. id ;
865
+ await this . buildCategorySlide ( this . editorInput . selectedCategory , undefined ) ;
866
+ this . setSlide ( 'details' ) ;
867
+ return ;
868
+ }
869
+ }
908
870
}
871
+
909
872
this . setSlide ( 'categories' ) ;
910
873
}
911
874
@@ -974,20 +937,10 @@ export class GettingStartedPage extends EditorPane {
974
937
975
938
recentlyOpenedList . onDidChange ( ( ) => this . registerDispatchListeners ( ) ) ;
976
939
977
- this . recentlyOpened . then ( ( { workspaces } ) => {
978
- // Filter out the current workspace
979
- const workspacesWithID = workspaces
980
- . filter ( recent => ! this . workspaceContextService . isCurrentWorkspace ( isRecentWorkspace ( recent ) ? recent . workspace : recent . folderUri ) )
981
- . map ( recent => ( { ...recent , id : isRecentWorkspace ( recent ) ? recent . workspace . id : recent . folderUri . toString ( ) } ) ) ;
982
-
983
- const updateEntries = ( ) => {
984
- recentlyOpenedList . setEntries ( workspacesWithID ) ;
985
- } ;
986
-
987
- updateEntries ( ) ;
940
+ const entries = this . recentlyOpened . workspaces . filter ( recent => ! this . workspaceContextService . isCurrentWorkspace ( isRecentWorkspace ( recent ) ? recent . workspace : recent . folderUri ) )
941
+ . map ( recent => ( { ...recent , id : isRecentWorkspace ( recent ) ? recent . workspace . id : recent . folderUri . toString ( ) } ) ) ;
988
942
989
- recentlyOpenedList . register ( this . labelService . onDidChangeFormatters ( ( ) => updateEntries ( ) ) ) ;
990
- } ) . catch ( onUnexpectedError ) ;
943
+ recentlyOpenedList . setEntries ( entries ) ;
991
944
992
945
return recentlyOpenedList ;
993
946
}
@@ -1151,14 +1104,12 @@ export class GettingStartedPage extends EditorPane {
1151
1104
contextService : this . contextService ,
1152
1105
} ) ;
1153
1106
1154
- this . featuredExtensions ?. then ( extensions => {
1155
- featuredExtensionsList . setEntries ( extensions ) ;
1156
- } ) ;
1107
+ featuredExtensionsList . setEntries ( this . featuredExtensions ) ;
1157
1108
1158
1109
this . featuredExtensionsList ?. onDidChange ( ( ) => {
1159
-
1160
1110
this . registerDispatchListeners ( ) ;
1161
1111
} ) ;
1112
+
1162
1113
return featuredExtensionsList ;
1163
1114
}
1164
1115
@@ -1207,12 +1158,22 @@ export class GettingStartedPage extends EditorPane {
1207
1158
}
1208
1159
1209
1160
private async scrollToCategory ( categoryID : string , stepId ?: string ) {
1161
+
1162
+ if ( ! this . gettingStartedCategories . some ( c => c . id === categoryID ) ) {
1163
+ this . gettingStartedCategories = await this . gettingStartedService . getWalkthroughs ( ) ;
1164
+ }
1165
+
1166
+ const ourCategory = this . gettingStartedCategories . find ( c => c . id === categoryID ) ;
1167
+ if ( ! ourCategory ) {
1168
+ throw Error ( 'Could not find category with ID: ' + categoryID ) ;
1169
+ }
1170
+
1210
1171
this . inProgressScroll = this . inProgressScroll . then ( async ( ) => {
1211
1172
reset ( this . stepsContent ) ;
1212
1173
this . editorInput . selectedCategory = categoryID ;
1213
1174
this . editorInput . selectedStep = stepId ;
1214
- this . currentWalkthrough = this . gettingStartedCategories . find ( category => category . id === categoryID ) ;
1215
- this . buildCategorySlide ( categoryID ) ;
1175
+ this . currentWalkthrough = ourCategory ;
1176
+ await this . buildCategorySlide ( categoryID ) ;
1216
1177
this . setSlide ( 'details' ) ;
1217
1178
} ) ;
1218
1179
}
@@ -1345,13 +1306,13 @@ export class GettingStartedPage extends EditorPane {
1345
1306
super . clearInput ( ) ;
1346
1307
}
1347
1308
1348
- private buildCategorySlide ( categoryID : string , selectedStep ?: string ) {
1309
+ private async buildCategorySlide ( categoryID : string , selectedStep ?: string ) {
1349
1310
if ( this . detailsScrollbar ) { this . detailsScrollbar . dispose ( ) ; }
1350
1311
1351
- this . extensionService . whenInstalledExtensionsRegistered ( ) . then ( ( ) => {
1352
- // Remove internal extension id specifier from exposed id's
1353
- this . extensionService . activateByEvent ( `onWalkthrough: ${ categoryID . replace ( / [ ^ # ] + # / , '' ) } ` ) ;
1354
- } ) ;
1312
+ await this . extensionService . whenInstalledExtensionsRegistered ( ) ;
1313
+
1314
+ // Remove internal extension id specifier from exposed id's
1315
+ await this . extensionService . activateByEvent ( `onWalkthrough: ${ categoryID . replace ( / [ ^ # ] + # / , '' ) } ` ) ;
1355
1316
1356
1317
this . detailsPageDisposables . clear ( ) ;
1357
1318
0 commit comments