From 5b6af0748264d83dc7a95f5f4b1c39196eaae8d9 Mon Sep 17 00:00:00 2001 From: Bhavya U Date: Thu, 27 Apr 2023 16:01:32 -0700 Subject: [PATCH] Move opening default built-in walkthrough to after built-in walkthrough initialization (#181066) --- .../browser/gettingStarted.ts | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts index 3b18b5a7e6fc1..0950d8f3008e5 100644 --- a/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts +++ b/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts @@ -242,7 +242,28 @@ export class GettingStartedPage extends EditorPane { } })); - this._register(this.gettingStartedService.onDidAddBuiltInWalkthrough(rerender)); + this._register(this.gettingStartedService.onDidAddBuiltInWalkthrough(() => { + rerender(); + const someStepsComplete = this.gettingStartedCategories.some(category => category.steps.find(s => s.done)); + if (!this.productService.openToWelcomeMainPage && !someStepsComplete && !this.hasScrolledToFirstCategory) { + const firstSessionDateString = this.storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION) || new Date().toUTCString(); + const daysSinceFirstSession = ((+new Date()) - (+new Date(firstSessionDateString))) / 1000 / 60 / 60 / 24; + const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index'; + + if (fistContentBehaviour === 'openToFirstCategory') { + const first = this.gettingStartedCategories.filter(c => !c.when || this.contextService.contextMatchesRules(c.when))[0]; + this.hasScrolledToFirstCategory = true; + if (first) { + this.currentWalkthrough = first; + this.editorInput.selectedCategory = this.currentWalkthrough?.id; + this.buildCategorySlide(this.editorInput.selectedCategory, undefined); + this.setSlide('details'); + return; + } + } + } + })); + this._register(this.gettingStartedService.onDidAddWalkthrough(rerender)); this._register(this.gettingStartedService.onDidRemoveWalkthrough(rerender)); @@ -872,29 +893,11 @@ export class GettingStartedPage extends EditorPane { } } - const someStepsComplete = this.gettingStartedCategories.some(category => category.steps.find(s => s.done)); if (this.editorInput.showTelemetryNotice && this.productService.openToWelcomeMainPage) { const telemetryNotice = $('p.telemetry-notice'); this.buildTelemetryFooter(telemetryNotice); footer.appendChild(telemetryNotice); - } else if (!this.productService.openToWelcomeMainPage && !someStepsComplete && !this.hasScrolledToFirstCategory) { - const firstSessionDateString = this.storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION) || new Date().toUTCString(); - const daysSinceFirstSession = ((+new Date()) - (+new Date(firstSessionDateString))) / 1000 / 60 / 60 / 24; - const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index'; - - if (fistContentBehaviour === 'openToFirstCategory') { - const first = this.gettingStartedCategories.filter(c => !c.when || this.contextService.contextMatchesRules(c.when))[0]; - this.hasScrolledToFirstCategory = true; - if (first) { - this.currentWalkthrough = first; - this.editorInput.selectedCategory = this.currentWalkthrough?.id; - this.buildCategorySlide(this.editorInput.selectedCategory, undefined); - this.setSlide('details'); - return; - } - } } - this.setSlide('categories'); }