From 2122b27eea02e499de7d1ac607a518f0c96d58dd Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Fri, 28 Apr 2023 08:16:12 +0200 Subject: [PATCH 1/2] Unexpected theme name showing up in web --- .../workbench/contrib/themes/browser/themes.contribution.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts index d2e559701458e..5dabeed9dc8c5 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts @@ -731,7 +731,8 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut private async _showYouGotMigratedNotification(): Promise { this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER); - const newThemeSettingsId = isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK; + const usingLight = this._workbenchThemeService.getColorTheme().type === ColorScheme.LIGHT; + const newThemeSettingsId = usingLight ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK; const newTheme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === newThemeSettingsId); if (newTheme) { const choices = [ @@ -752,7 +753,7 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut label: localize('button.revert', "Revert"), run: async () => { this._writeTelemetry('keepOld'); - const oldSettingsId = isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD : ThemeSettingDefaults.COLOR_THEME_DARK_OLD; + const oldSettingsId = usingLight ? ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD : ThemeSettingDefaults.COLOR_THEME_DARK_OLD; const oldTheme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === oldSettingsId); if (oldTheme) { this._workbenchThemeService.setColorTheme(oldTheme, 'auto'); From ba24a9fc88e9fd65f0a5d6e2984bacc0d94057bb Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Fri, 28 Apr 2023 11:37:16 +0200 Subject: [PATCH 2/2] incorperate feedback --- .../themes/browser/themes.contribution.ts | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts index 5dabeed9dc8c5..2510f349244b1 100644 --- a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts +++ b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts @@ -43,6 +43,7 @@ import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notif import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { isWeb } from 'vs/base/common/platform'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IHostService } from 'vs/workbench/services/host/browser/host'; export const manageExtensionIcon = registerIcon('theme-selection-manage-extension', Codicon.gear, localize('manageExtensionIcon', 'Icon for the \'Manage\' action in the theme selection quick pick.')); @@ -711,26 +712,30 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut @IStorageService private readonly _storageService: IStorageService, @ICommandService private readonly _commandService: ICommandService, @ITelemetryService private readonly _telemetryService: ITelemetryService, + @IHostService private readonly _hostService: IHostService, ) { if (_storageService.getBoolean(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, StorageScope.APPLICATION)) { return; } - if (this._workbenchThemeService.hasUpdatedDefaultThemes()) { - setTimeout(() => { - this._showYouGotMigratedNotification(); - }, 6000); - } else { - const currentTheme = this._workbenchThemeService.getColorTheme().settingsId; - if (currentTheme === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD || currentTheme === ThemeSettingDefaults.COLOR_THEME_DARK_OLD) { - setTimeout(() => { - this._tryNewThemeNotification(); - }, 6000); + setTimeout(async () => { + if (_storageService.getBoolean(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, StorageScope.APPLICATION)) { + return; } - } + if (await this._hostService.hadLastFocus()) { + this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER); + if (this._workbenchThemeService.hasUpdatedDefaultThemes()) { + this._showYouGotMigratedNotification(); + } else { + const currentTheme = this._workbenchThemeService.getColorTheme().settingsId; + if (currentTheme === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD || currentTheme === ThemeSettingDefaults.COLOR_THEME_DARK_OLD) { + this._tryNewThemeNotification(); + } + } + } + }, 6000); } private async _showYouGotMigratedNotification(): Promise { - this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER); const usingLight = this._workbenchThemeService.getColorTheme().type === ColorScheme.LIGHT; const newThemeSettingsId = usingLight ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK; const newTheme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === newThemeSettingsId); @@ -773,7 +778,6 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut } private async _tryNewThemeNotification(): Promise { - this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER); const newThemeSettingsId = this._workbenchThemeService.getColorTheme().type === ColorScheme.LIGHT ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK; const theme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === newThemeSettingsId); if (theme) {