Mailspring/internal_packages/system-tray/lib/main.es6
Juan Tejada b3a9f31051 fix(tray): Prevent system tray from being initialized more than once
- Makes sure the tray is deactivated before activating
2015-11-23 09:31:10 -08:00

34 lines
710 B
JavaScript

import SystemTray from './system-tray';
const platform = process.platform;
let systemTray;
let unsubConfig = ()=>{};
const onSystemTrayToggle = (showSystemTray)=> {
if (showSystemTray.newValue) {
systemTray = new SystemTray(platform);
} else {
systemTray.destroy();
systemTray = null;
}
};
export function deactivate() {
if (systemTray) {
systemTray.destroy();
systemTray = null;
}
unsubConfig();
}
export function activate() {
deactivate();
unsubConfig = NylasEnv.config.onDidChange('core.showSystemTray', onSystemTrayToggle).dispose;
if (NylasEnv.config.get('core.showSystemTray')) {
systemTray = new SystemTray(platform);
}
}
export function serialize() {
}