Skip to content

Commit 0389468

Browse files
authored
Unexpected theme name showing up in web (microsoft#181091)
* Unexpected theme name showing up in web * incorperate feedback
1 parent 68b2de2 commit 0389468

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/vs/workbench/contrib/themes/browser/themes.contribution.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notif
4343
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
4444
import { isWeb } from 'vs/base/common/platform';
4545
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
46+
import { IHostService } from 'vs/workbench/services/host/browser/host';
4647

4748
export const manageExtensionIcon = registerIcon('theme-selection-manage-extension', Codicon.gear, localize('manageExtensionIcon', 'Icon for the \'Manage\' action in the theme selection quick pick.'));
4849

@@ -711,27 +712,32 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut
711712
@IStorageService private readonly _storageService: IStorageService,
712713
@ICommandService private readonly _commandService: ICommandService,
713714
@ITelemetryService private readonly _telemetryService: ITelemetryService,
715+
@IHostService private readonly _hostService: IHostService,
714716
) {
715717
if (_storageService.getBoolean(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, StorageScope.APPLICATION)) {
716718
return;
717719
}
718-
if (this._workbenchThemeService.hasUpdatedDefaultThemes()) {
719-
setTimeout(() => {
720-
this._showYouGotMigratedNotification();
721-
}, 6000);
722-
} else {
723-
const currentTheme = this._workbenchThemeService.getColorTheme().settingsId;
724-
if (currentTheme === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD || currentTheme === ThemeSettingDefaults.COLOR_THEME_DARK_OLD) {
725-
setTimeout(() => {
726-
this._tryNewThemeNotification();
727-
}, 6000);
720+
setTimeout(async () => {
721+
if (_storageService.getBoolean(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, StorageScope.APPLICATION)) {
722+
return;
728723
}
729-
}
724+
if (await this._hostService.hadLastFocus()) {
725+
this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
726+
if (this._workbenchThemeService.hasUpdatedDefaultThemes()) {
727+
this._showYouGotMigratedNotification();
728+
} else {
729+
const currentTheme = this._workbenchThemeService.getColorTheme().settingsId;
730+
if (currentTheme === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD || currentTheme === ThemeSettingDefaults.COLOR_THEME_DARK_OLD) {
731+
this._tryNewThemeNotification();
732+
}
733+
}
734+
}
735+
}, 6000);
730736
}
731737

732738
private async _showYouGotMigratedNotification(): Promise<void> {
733-
this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
734-
const newThemeSettingsId = isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK;
739+
const usingLight = this._workbenchThemeService.getColorTheme().type === ColorScheme.LIGHT;
740+
const newThemeSettingsId = usingLight ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK;
735741
const newTheme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === newThemeSettingsId);
736742
if (newTheme) {
737743
const choices = [
@@ -752,7 +758,7 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut
752758
label: localize('button.revert', "Revert"),
753759
run: async () => {
754760
this._writeTelemetry('keepOld');
755-
const oldSettingsId = isWeb ? ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD : ThemeSettingDefaults.COLOR_THEME_DARK_OLD;
761+
const oldSettingsId = usingLight ? ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD : ThemeSettingDefaults.COLOR_THEME_DARK_OLD;
756762
const oldTheme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === oldSettingsId);
757763
if (oldTheme) {
758764
this._workbenchThemeService.setColorTheme(oldTheme, 'auto');
@@ -772,7 +778,6 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut
772778
}
773779

774780
private async _tryNewThemeNotification(): Promise<void> {
775-
this._storageService.store(DefaultThemeUpdatedNotificationContribution.STORAGE_KEY, true, StorageScope.APPLICATION, StorageTarget.USER);
776781
const newThemeSettingsId = this._workbenchThemeService.getColorTheme().type === ColorScheme.LIGHT ? ThemeSettingDefaults.COLOR_THEME_LIGHT : ThemeSettingDefaults.COLOR_THEME_DARK;
777782
const theme = (await this._workbenchThemeService.getColorThemes()).find(theme => theme.settingsId === newThemeSettingsId);
778783
if (theme) {

0 commit comments

Comments
 (0)