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

Show theme update notification dialog only on window in focus #181329

Merged
merged 1 commit into from May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/vs/workbench/contrib/themes/browser/themes.contribution.ts
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,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();
}
}
}
}, 3000);
}

private async _showYouGotMigratedNotification(): Promise<void> {
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);
Expand Down Expand Up @@ -773,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 Expand Up @@ -818,4 +822,4 @@ class DefaultThemeUpdatedNotificationContribution implements IWorkbenchContribut
}
}
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(Extensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(DefaultThemeUpdatedNotificationContribution, LifecyclePhase.Ready);
workbenchRegistry.registerWorkbenchContribution(DefaultThemeUpdatedNotificationContribution, LifecyclePhase.Eventually);