fix(tray): Prevent system tray from being initialized more than once

- Makes sure the tray is deactivated before activating
This commit is contained in:
Juan Tejada 2015-11-21 19:05:29 -08:00
parent 0258b99870
commit cc536c1268

View file

@ -2,7 +2,7 @@ import SystemTray from './system-tray';
const platform = process.platform; const platform = process.platform;
let systemTray; let systemTray;
let unsubConfig; let unsubConfig = ()=>{};
const onSystemTrayToggle = (showSystemTray)=> { const onSystemTrayToggle = (showSystemTray)=> {
if (showSystemTray.newValue) { if (showSystemTray.newValue) {
systemTray = new SystemTray(platform); systemTray = new SystemTray(platform);
@ -12,13 +12,6 @@ const onSystemTrayToggle = (showSystemTray)=> {
} }
}; };
export function activate() {
unsubConfig = NylasEnv.config.onDidChange('core.showSystemTray', onSystemTrayToggle).dispose;
if (NylasEnv.config.get('core.showSystemTray')) {
systemTray = new SystemTray(platform);
}
}
export function deactivate() { export function deactivate() {
if (systemTray) { if (systemTray) {
systemTray.destroy(); systemTray.destroy();
@ -27,6 +20,14 @@ export function deactivate() {
unsubConfig(); 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() { export function serialize() {
} }