diff options
author | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2021-11-08 14:36:02 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 09:06:02 +0000 |
commit | 008056f07107bb206546ab27f4437d6d53752d90 (patch) | |
tree | 348b90aa6e86014bc3177cf58a0ab6b7f8ab446f | |
parent | Bumped up ferdi to '5.6.4-nightly.0' [skip ci] (diff) | |
download | ferdium-app-008056f07107bb206546ab27f4437d6d53752d90.tar.gz ferdium-app-008056f07107bb206546ab27f4437d6d53752d90.tar.zst ferdium-app-008056f07107bb206546ab27f4437d6d53752d90.zip |
fix: check if 'app.mainWindow' is present to avoid js errors (#2189)
-rw-r--r-- | src/lib/Tray.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index e7afc3552..eb6732c30 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -32,6 +32,9 @@ export default class TrayIcon { | |||
32 | { | 32 | { |
33 | label: 'Show Ferdi', | 33 | label: 'Show Ferdi', |
34 | click() { | 34 | click() { |
35 | if (!app.mainWindow) { | ||
36 | return; | ||
37 | } | ||
35 | if (app.mainWindow.isMinimized()) { | 38 | if (app.mainWindow.isMinimized()) { |
36 | app.mainWindow.restore(); | 39 | app.mainWindow.restore(); |
37 | } else if (app.mainWindow.isVisible()) { | 40 | } else if (app.mainWindow.isVisible()) { |
@@ -45,6 +48,9 @@ export default class TrayIcon { | |||
45 | { | 48 | { |
46 | label: 'Disable Notifications & Audio', | 49 | label: 'Disable Notifications & Audio', |
47 | click() { | 50 | click() { |
51 | if (!app.mainWindow) { | ||
52 | return; | ||
53 | } | ||
48 | app.mainWindow.webContents.send('muteApp'); | 54 | app.mainWindow.webContents.send('muteApp'); |
49 | }, | 55 | }, |
50 | }, | 56 | }, |
@@ -99,6 +105,9 @@ export default class TrayIcon { | |||
99 | } | 105 | } |
100 | 106 | ||
101 | this.trayIcon.on('click', () => { | 107 | this.trayIcon.on('click', () => { |
108 | if (!app.mainWindow) { | ||
109 | return; | ||
110 | } | ||
102 | if (app.mainWindow.isMinimized()) { | 111 | if (app.mainWindow.isMinimized()) { |
103 | app.mainWindow.restore(); | 112 | app.mainWindow.restore(); |
104 | } else if (app.mainWindow.isVisible()) { | 113 | } else if (app.mainWindow.isVisible()) { |