diff options
Diffstat (limited to 'src/stores/UIStore.js')
-rw-r--r-- | src/stores/UIStore.js | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js index 9680c5bcc..6941cf086 100644 --- a/src/stores/UIStore.js +++ b/src/stores/UIStore.js | |||
@@ -1,23 +1,41 @@ | |||
1 | import { | 1 | import { |
2 | action, | 2 | action, observable, computed, reaction, |
3 | observable, | ||
4 | computed, | ||
5 | reaction, | ||
6 | } from 'mobx'; | 3 | } from 'mobx'; |
7 | import { theme } from '@meetfranz/theme'; | 4 | import { theme } from '@meetfranz/theme'; |
5 | import { remote } from 'electron'; | ||
8 | 6 | ||
9 | import Store from './lib/Store'; | 7 | import Store from './lib/Store'; |
8 | import { isMac } from '../environment'; | ||
9 | |||
10 | const { nativeTheme, systemPreferences } = remote; | ||
10 | 11 | ||
11 | export default class UIStore extends Store { | 12 | export default class UIStore extends Store { |
12 | @observable showServicesUpdatedInfoBar = false; | 13 | @observable showServicesUpdatedInfoBar = false; |
13 | 14 | ||
15 | @observable isOsDarkThemeActive = isMac | ||
16 | ? nativeTheme.shouldUseDarkColors | ||
17 | : false; | ||
18 | |||
14 | constructor(...args) { | 19 | constructor(...args) { |
15 | super(...args); | 20 | super(...args); |
16 | 21 | ||
17 | // Register action handlers | 22 | // Register action handlers |
18 | this.actions.ui.openSettings.listen(this._openSettings.bind(this)); | 23 | this.actions.ui.openSettings.listen(this._openSettings.bind(this)); |
19 | this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); | 24 | this.actions.ui.closeSettings.listen(this._closeSettings.bind(this)); |
20 | this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); | 25 | this.actions.ui.toggleServiceUpdatedInfoBar.listen( |
26 | this._toggleServiceUpdatedInfoBar.bind(this), | ||
27 | ); | ||
28 | |||
29 | // Listen for theme change on MacOS | ||
30 | if (isMac) { | ||
31 | systemPreferences.subscribeNotification( | ||
32 | 'AppleInterfaceThemeChangedNotification', | ||
33 | () => { | ||
34 | this.isOsDarkThemeActive = nativeTheme.shouldUseDarkColors; | ||
35 | this.actions.service.shareSettingsWithServiceProcess(); | ||
36 | }, | ||
37 | ); | ||
38 | } | ||
21 | } | 39 | } |
22 | 40 | ||
23 | setup() { | 41 | setup() { |
@@ -31,11 +49,23 @@ export default class UIStore extends Store { | |||
31 | @computed get showMessageBadgesEvenWhenMuted() { | 49 | @computed get showMessageBadgesEvenWhenMuted() { |
32 | const settings = this.stores.settings.all; | 50 | const settings = this.stores.settings.all; |
33 | 51 | ||
34 | return (settings.app.isAppMuted && settings.app.showMessageBadgeWhenMuted) || !settings.app.isAppMuted; | 52 | return ( |
53 | (settings.app.isAppMuted && settings.app.showMessageBadgeWhenMuted) | ||
54 | || !settings.app.isAppMuted | ||
55 | ); | ||
35 | } | 56 | } |
36 | 57 | ||
37 | @computed get isDarkThemeActive() { | 58 | @computed get isDarkThemeActive() { |
38 | return this.stores.settings.all.app.darkMode; | 59 | const isMacWithAdaptableInDarkMode = isMac |
60 | && this.stores.settings.all.app.adaptableDarkMode | ||
61 | && this.isOsDarkThemeActive; | ||
62 | const isMacWithoutAdaptableInDarkMode = isMac | ||
63 | && this.stores.settings.all.app.darkMode | ||
64 | && !this.stores.settings.all.app.adaptableDarkMode; | ||
65 | const isNotMacInDarkMode = !isMac && this.stores.settings.all.app.darkMode; | ||
66 | return !!(isMacWithAdaptableInDarkMode | ||
67 | || isMacWithoutAdaptableInDarkMode | ||
68 | || isNotMacInDarkMode); | ||
39 | } | 69 | } |
40 | 70 | ||
41 | @computed get theme() { | 71 | @computed get theme() { |