mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-08 13:44:53 +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 systemTray;
|
||||||
let unsubConfig = ()=>{};
|
let unsubConfig = ()=>{};
|
||||||
const onSystemTrayToggle = (showSystemTray)=> {
|
|
||||||
if (showSystemTray.newValue) {
|
|
||||||
systemTray = new SystemTray(platform);
|
|
||||||
} else {
|
|
||||||
systemTray.destroy();
|
|
||||||
systemTray = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export function deactivate() {
|
export function deactivate() {
|
||||||
if (systemTray) {
|
if (systemTray) {
|
||||||
|
@ -22,6 +14,13 @@ export function deactivate() {
|
||||||
|
|
||||||
export function activate() {
|
export function activate() {
|
||||||
deactivate();
|
deactivate();
|
||||||
|
const onSystemTrayToggle = (showSystemTray)=> {
|
||||||
|
deactivate();
|
||||||
|
if (showSystemTray.newValue) {
|
||||||
|
systemTray = new SystemTray(platform);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
unsubConfig = NylasEnv.config.onDidChange('core.showSystemTray', onSystemTrayToggle).dispose;
|
unsubConfig = NylasEnv.config.onDidChange('core.showSystemTray', onSystemTrayToggle).dispose;
|
||||||
if (NylasEnv.config.get('core.showSystemTray')) {
|
if (NylasEnv.config.get('core.showSystemTray')) {
|
||||||
systemTray = new SystemTray(platform);
|
systemTray = new SystemTray(platform);
|
||||||
|
|
Loading…
Add table
Reference in a new issue