Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected theme name showing up in web #181091

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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