feat(Reload notification): added support for after-install notification

This commit is contained in:
LasaleFamine 2018-08-12 11:52:58 +02:00
parent 0ecb7ff066
commit a42b3a0f86
3 changed files with 33 additions and 5 deletions

View file

@ -12,14 +12,30 @@ const MESSAGES = {
CHANGELOG: { CHANGELOG: {
message: 'Material Theme was updated. Check the release notes for more details.', message: 'Material Theme was updated. Check the release notes for more details.',
options: {ok: 'Show me', cancel: 'Maybe later'} options: {ok: 'Show me', cancel: 'Maybe later'}
},
INSTALLATION: {
message: 'Thank you for installing Material Theme! Would you like to enable the auto-application (with window reload when needed) of the Material Theme icons?',
options: {ok: 'Sure!', cancel: 'Nope :('}
} }
}; };
export const infoMessage = async () => { export const infoMessage = async () => {
if (await Window.showInformationMessage(MESSAGES.INFO.message, MESSAGES.INFO.options.ok, MESSAGES.INFO.options.cancel) === MESSAGES.INFO.options.ok) { if (await Window.showInformationMessage(
MESSAGES.INFO.message,
...MESSAGES.INFO.options as any
) === MESSAGES.INFO.options.ok) {
ThemeCommands.fixIcons(); ThemeCommands.fixIcons();
} }
}; };
export const changelogMessage = async () => export const changelogMessage = async () =>
await Window.showInformationMessage(MESSAGES.CHANGELOG.message, MESSAGES.CHANGELOG.options.ok, MESSAGES.CHANGELOG.options.cancel) === MESSAGES.CHANGELOG.options.ok; await Window.showInformationMessage(
MESSAGES.CHANGELOG.message,
...MESSAGES.CHANGELOG.options as any
) === MESSAGES.CHANGELOG.options.ok;
export const installationMessage = async () =>
await Window.showInformationMessage(
MESSAGES.INSTALLATION.message,
...MESSAGES.INSTALLATION.options as any
) === MESSAGES.INSTALLATION.options.ok;

View file

@ -4,9 +4,9 @@ import {
} from 'vscode'; } from 'vscode';
import * as ThemeCommands from './commands'; import * as ThemeCommands from './commands';
import {isAutoApplyEnable} from './helpers/settings'; import {isAutoApplyEnable, setCustomSetting} from './helpers/settings';
import {onChangeConfiguration} from './helpers/configuration-change'; import {onChangeConfiguration} from './helpers/configuration-change';
import {infoMessage, changelogMessage} from './helpers/messages'; import {infoMessage, changelogMessage, installationMessage} from './helpers/messages';
import checkInstallation from './helpers/check-installation'; import checkInstallation from './helpers/check-installation';
import writeChangelog from './helpers/write-changelog'; import writeChangelog from './helpers/write-changelog';
@ -24,6 +24,13 @@ export async function activate() {
config.update('materialTheme.cache.workbench', undefined, true); config.update('materialTheme.cache.workbench', undefined, true);
} }
if (installationType.isFirstInstall) {
const enableAutoApply = await installationMessage();
await setCustomSetting('autoApplyIcons', enableAutoApply);
// Set true always on new installation
await setCustomSetting('showReloadNotification', true);
}
const shouldShowChangelog = (installationType.isFirstInstall || installationType.isUpdate) && await changelogMessage(); const shouldShowChangelog = (installationType.isFirstInstall || installationType.isUpdate) && await changelogMessage();
if (shouldShowChangelog) { if (shouldShowChangelog) {
ThemeCommands.showChangelog(); ThemeCommands.showChangelog();

View file

@ -93,7 +93,12 @@
}, },
"materialTheme.autoApplyIcons": { "materialTheme.autoApplyIcons": {
"type": "boolean", "type": "boolean",
"description": "Enable/disable auto-apply of Material Theme icons", "description": "Enable/disable auto-apply of Material Theme icons with window reload when needed",
"default": false
},
"materialTheme.showReloadNotification": {
"type": "boolean",
"description": "Useful when autoApplyIcons is false and you want to be asked to reload the window when needed",
"default": true "default": true
}, },
"materialTheme.fixIconsRunning": { "materialTheme.fixIconsRunning": {