diff --git a/src/vs/workbench/contrib/themes/browser/themes.contribution.ts b/src/vs/workbench/contrib/themes/browser/themes.contribution.ts index d2e559701458e..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,27 +712,32 @@ 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 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 +758,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'); @@ -772,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) {