mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-07 05:04:58 +08:00
fix(tray): Prevent duplicate trays on preference changes
This commit is contained in:
parent
cc536c1268
commit
8ac340cbb4
1 changed files with 7 additions and 8 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue