2018-04-30 09:55:47 +02:00
|
|
|
import {
|
|
|
|
workspace as Workspace,
|
|
|
|
commands as Commands
|
|
|
|
} from 'vscode';
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-05-18 13:47:22 +02:00
|
|
|
import * as ThemeCommands from './commands';
|
2018-08-12 19:09:36 +02:00
|
|
|
import {setCustomSetting} from './helpers/settings';
|
2018-05-18 13:47:22 +02:00
|
|
|
import {onChangeConfiguration} from './helpers/configuration-change';
|
2018-08-12 19:09:36 +02:00
|
|
|
import {changelogMessage, installationMessage} from './helpers/messages';
|
|
|
|
import checkInstallation from './helpers/check-installation';
|
|
|
|
import writeChangelog from './helpers/write-changelog';
|
|
|
|
import handleAutoapply from './helpers/handle-autoapply';
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-06-21 23:02:57 +02:00
|
|
|
export async function activate() {
|
2018-04-30 09:55:47 +02:00
|
|
|
const config = Workspace.getConfiguration();
|
2018-08-12 19:09:36 +02:00
|
|
|
const installationType = checkInstallation();
|
|
|
|
|
|
|
|
writeChangelog();
|
2018-04-20 20:07:36 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
|
2018-05-18 13:47:22 +02:00
|
|
|
Workspace.onDidChangeConfiguration(onChangeConfiguration);
|
2018-04-21 18:17:20 +02:00
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Delete old configuration, must remove with next major release
|
|
|
|
if (config.has('materialTheme.cache.workbench')) {
|
|
|
|
config.update('materialTheme.cache.workbench', undefined, true);
|
|
|
|
}
|
|
|
|
|
2018-08-12 19:09:36 +02:00
|
|
|
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();
|
|
|
|
if (shouldShowChangelog) {
|
|
|
|
ThemeCommands.showChangelog();
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|
|
|
|
|
2018-04-30 09:55:47 +02:00
|
|
|
// Registering commands
|
2018-05-18 13:47:22 +02:00
|
|
|
Commands.registerCommand('materialTheme.setAccent', async () => {
|
|
|
|
const wasSet = await ThemeCommands.accentsSetter();
|
2018-08-12 19:09:36 +02:00
|
|
|
handleAutoapply(wasSet);
|
2018-05-18 13:47:22 +02:00
|
|
|
});
|
|
|
|
Commands.registerCommand('materialTheme.fixIcons', () => ThemeCommands.fixIcons());
|
|
|
|
Commands.registerCommand('materialTheme.toggleApplyIcons', () => ThemeCommands.toggleApplyIcons());
|
|
|
|
Commands.registerCommand('materialTheme.showChangelog', () => ThemeCommands.showChangelog());
|
2018-04-20 20:07:36 +02:00
|
|
|
}
|