mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-04 07:10:06 +08:00
fix(tray): Prevent system tray from being initialized more than once
- Makes sure the tray is deactivated before activating
This commit is contained in:
parent
0258b99870
commit
cc536c1268
1 changed files with 9 additions and 8 deletions
|
@ -2,7 +2,7 @@ import SystemTray from './system-tray';
|
|||
const platform = process.platform;
|
||||
|
||||
let systemTray;
|
||||
let unsubConfig;
|
||||
let unsubConfig = ()=>{};
|
||||
const onSystemTrayToggle = (showSystemTray)=> {
|
||||
if (showSystemTray.newValue) {
|
||||
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() {
|
||||
if (systemTray) {
|
||||
systemTray.destroy();
|
||||
|
@ -27,6 +20,14 @@ export function deactivate() {
|
|||
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() {
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue