Skip to content

Commit 614287f

Browse files
authored
Add first session date handling to welcome page logic (microsoft#264185)
1 parent ddfba4f commit 614287f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { IOpenerService } from '../../../../platform/opener/common/opener.js';
4545
import { IProductService } from '../../../../platform/product/common/productService.js';
4646
import { IQuickInputService } from '../../../../platform/quickinput/common/quickInput.js';
4747
import { IStorageService, StorageScope, StorageTarget, WillSaveStateReason } from '../../../../platform/storage/common/storage.js';
48-
import { ITelemetryService, TelemetryLevel } from '../../../../platform/telemetry/common/telemetry.js';
48+
import { firstSessionDateStorageKey, ITelemetryService, TelemetryLevel } from '../../../../platform/telemetry/common/telemetry.js';
4949
import { getTelemetryLevel } from '../../../../platform/telemetry/common/telemetryUtils.js';
5050
import { defaultButtonStyles, defaultKeybindingLabelStyles, defaultToggleStyles } from '../../../../platform/theme/browser/defaultStyles.js';
5151
import { IWindowOpenable } from '../../../../platform/window/common/window.js';
@@ -941,6 +941,22 @@ export class GettingStartedPage extends EditorPane {
941941
const telemetryNotice = $('p.telemetry-notice');
942942
this.buildTelemetryFooter(telemetryNotice);
943943
footer.appendChild(telemetryNotice);
944+
} else if (!this.productService.openToWelcomeMainPage && this.showFeaturedWalkthrough && this.storageService.isNew(StorageScope.APPLICATION)) {
945+
const firstSessionDateString = this.storageService.get(firstSessionDateStorageKey, StorageScope.APPLICATION) || new Date().toUTCString();
946+
const daysSinceFirstSession = ((+new Date()) - (+new Date(firstSessionDateString))) / 1000 / 60 / 60 / 24;
947+
const fistContentBehaviour = daysSinceFirstSession < 1 ? 'openToFirstCategory' : 'index';
948+
949+
if (fistContentBehaviour === 'openToFirstCategory') {
950+
const first = this.gettingStartedCategories.filter(c => !c.when || this.contextService.contextMatchesRules(c.when))[0];
951+
if (first) {
952+
this.currentWalkthrough = first;
953+
this.editorInput.selectedCategory = this.currentWalkthrough?.id;
954+
this.editorInput.walkthroughPageTitle = this.currentWalkthrough.walkthroughPageTitle;
955+
this.buildCategorySlide(this.editorInput.selectedCategory, undefined);
956+
this.setSlide('details', true /* firstLaunch */);
957+
return;
958+
}
959+
}
944960
}
945961

946962
this.setSlide('categories');

0 commit comments

Comments
 (0)