Skip to content

Commit

Permalink
Unexpected theme name showing up in web (#181091)
Browse files Browse the repository at this point in the history
* Unexpected theme name showing up in web

* incorperate feedback
  • Loading branch information
aeschli authored Apr 28, 2023
1 parent 68b2de2 commit 0389468
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/vs/workbench/contrib/themes/browser/themes.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));

Expand Down Expand Up @@ -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<void> {
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 = [
Expand All @@ -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');
Expand All @@ -772,7 +778,6 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut
}

private async _tryNewThemeNotification(): Promise<void> {
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) {
Expand Down

0 comments on commit 0389468

Please sign in to comment.