diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Tray.js | 66 | ||||
-rw-r--r-- | src/stores/AppStore.js | 4 | ||||
-rw-r--r-- | src/stores/SettingsStore.js | 1 |
3 files changed, 51 insertions, 20 deletions
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 84ee8e3bb..3700cca27 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -1,5 +1,5 @@ | |||
1 | import { | 1 | import { |
2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, | 2 | app, Menu, nativeImage, nativeTheme, systemPreferences, Tray, ipcMain, |
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | 5 | ||
@@ -14,29 +14,55 @@ export default class TrayIcon { | |||
14 | 14 | ||
15 | themeChangeSubscriberId = null; | 15 | themeChangeSubscriberId = null; |
16 | 16 | ||
17 | trayMenu = null; | ||
18 | |||
19 | trayMenuTemplate = [ | ||
20 | { | ||
21 | label: 'Show Ferdi', | ||
22 | click() { | ||
23 | if (app.mainWindow.isMinimized()) { | ||
24 | app.mainWindow.restore(); | ||
25 | } | ||
26 | app.mainWindow.show(); | ||
27 | app.mainWindow.focus(); | ||
28 | }, | ||
29 | }, | ||
30 | { | ||
31 | label: 'Disable Notifications & Audio', | ||
32 | click() { | ||
33 | app.mainWindow.webContents.send('muteApp'); | ||
34 | }, | ||
35 | }, | ||
36 | { | ||
37 | label: 'Quit Ferdi', | ||
38 | click() { | ||
39 | app.quit(); | ||
40 | }, | ||
41 | }, | ||
42 | ]; | ||
43 | |||
44 | _updateTrayMenu(appSettings) { | ||
45 | if (appSettings.type === 'app') { | ||
46 | const { isAppMuted } = appSettings.data; | ||
47 | this.trayMenuTemplate[1].label = isAppMuted ? 'Enable Notifications && Audio' : 'Disable Notifications && Audio'; | ||
48 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); | ||
49 | } | ||
50 | } | ||
51 | |||
17 | show() { | 52 | show() { |
18 | if (this.trayIcon) return; | 53 | if (this.trayIcon) return; |
19 | 54 | ||
20 | this.trayIcon = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN)); | 55 | this.trayIcon = new Tray(this._getAsset('tray', INDICATOR_TRAY_PLAIN)); |
21 | const trayMenuTemplate = [ | ||
22 | { | ||
23 | label: 'Show Ferdi', | ||
24 | click() { | ||
25 | if (app.mainWindow.isMinimized()) { | ||
26 | app.mainWindow.restore(); | ||
27 | } | ||
28 | app.mainWindow.show(); | ||
29 | app.mainWindow.focus(); | ||
30 | }, | ||
31 | }, { | ||
32 | label: 'Quit Ferdi', | ||
33 | click() { | ||
34 | app.quit(); | ||
35 | }, | ||
36 | }, | ||
37 | ]; | ||
38 | 56 | ||
39 | const trayMenu = Menu.buildFromTemplate(trayMenuTemplate); | 57 | this.trayMenu = Menu.buildFromTemplate(this.trayMenuTemplate); |
58 | |||
59 | ipcMain.on('initialAppSettings', (event, appSettings) => { | ||
60 | this._updateTrayMenu(appSettings); | ||
61 | }); | ||
62 | |||
63 | ipcMain.on('updateAppSettings', (event, appSettings) => { | ||
64 | this._updateTrayMenu(appSettings); | ||
65 | }); | ||
40 | 66 | ||
41 | this.trayIcon.on('click', () => { | 67 | this.trayIcon.on('click', () => { |
42 | if (app.mainWindow.isMinimized()) { | 68 | if (app.mainWindow.isMinimized()) { |
@@ -50,7 +76,7 @@ export default class TrayIcon { | |||
50 | }); | 76 | }); |
51 | 77 | ||
52 | this.trayIcon.on('right-click', () => { | 78 | this.trayIcon.on('right-click', () => { |
53 | this.trayIcon.popUpContextMenu(trayMenu); | 79 | this.trayIcon.popUpContextMenu(this.trayMenu); |
54 | }); | 80 | }); |
55 | 81 | ||
56 | if (process.platform === 'darwin') { | 82 | if (process.platform === 'darwin') { |
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 593bf341e..c8adb9c3c 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -179,6 +179,10 @@ export default class AppStore extends Store { | |||
179 | this.stores.router.push(url); | 179 | this.stores.router.push(url); |
180 | }); | 180 | }); |
181 | 181 | ||
182 | ipcRenderer.on('muteApp', () => { | ||
183 | this._toggleMuteApp(); | ||
184 | }); | ||
185 | |||
182 | this.locale = this._getDefaultLocale(); | 186 | this.locale = this._getDefaultLocale(); |
183 | 187 | ||
184 | setTimeout(() => { | 188 | setTimeout(() => { |
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index 799ba3f5a..227eb2145 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -110,6 +110,7 @@ export default class SettingsStore extends Store { | |||
110 | } | 110 | } |
111 | debug('Get appSettings resolves', resp.type, resp.data); | 111 | debug('Get appSettings resolves', resp.type, resp.data); |
112 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); | 112 | Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); |
113 | ipcRenderer.send('initialAppSettings', resp); | ||
113 | }); | 114 | }); |
114 | 115 | ||
115 | this.fileSystemSettingsTypes.forEach((type) => { | 116 | this.fileSystemSettingsTypes.forEach((type) => { |