mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +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;
|
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() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue