fix(tray): Prevent duplicate trays on preference changes

This commit is contained in:
Juan Tejada 2015-11-23 09:53:05 -08:00
parent cc536c1268
commit 8ac340cbb4

View file

@ -3,14 +3,6 @@ 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) {
@ -22,6 +14,13 @@ export function deactivate() {
export function activate() {
deactivate();
const onSystemTrayToggle = (showSystemTray)=> {
deactivate();
if (showSystemTray.newValue) {
systemTray = new SystemTray(platform);
}
};
unsubConfig = NylasEnv.config.onDidChange('core.showSystemTray', onSystemTrayToggle).dispose;
if (NylasEnv.config.get('core.showSystemTray')) {
systemTray = new SystemTray(platform);