diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-12-02 15:08:07 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-12-02 15:08:07 +0100 |
commit | a5aa5e1380a0847eb33be3315d164fb9e0e23255 (patch) | |
tree | a1ea4b0f635cabb54d9cf028809d2f079727b9a1 /src/stores/AppStore.js | |
parent | Add instruction to install Franz with homebrew (#1134) (diff) | |
parent | Merge branch 'develop' into release/5.0.0-beta.19 (diff) | |
download | ferdium-app-a5aa5e1380a0847eb33be3315d164fb9e0e23255.tar.gz ferdium-app-a5aa5e1380a0847eb33be3315d164fb9e0e23255.tar.zst ferdium-app-a5aa5e1380a0847eb33be3315d164fb9e0e23255.zip |
Merge branch 'release/5.0.0-beta.19'
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r-- | src/stores/AppStore.js | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 38edff1b4..6f156a96d 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js | |||
@@ -12,12 +12,14 @@ import { CHECK_INTERVAL, DEFAULT_APP_SETTINGS } from '../config'; | |||
12 | import { isMac, isLinux, isWindows } from '../environment'; | 12 | import { isMac, isLinux, isWindows } from '../environment'; |
13 | import locales from '../i18n/translations'; | 13 | import locales from '../i18n/translations'; |
14 | import { gaEvent } from '../lib/analytics'; | 14 | import { gaEvent } from '../lib/analytics'; |
15 | import { onVisibilityChange } from '../helpers/visibility-helper'; | ||
16 | import { getLocale } from '../helpers/i18n-helpers'; | ||
15 | 17 | ||
16 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; | 18 | import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; |
17 | 19 | ||
18 | const debug = require('debug')('AppStore'); | 20 | const debug = require('debug')('Franz:AppStore'); |
19 | 21 | ||
20 | const { app } = remote; | 22 | const { app, systemPreferences } = remote; |
21 | 23 | ||
22 | const mainWindow = remote.getCurrentWindow(); | 24 | const mainWindow = remote.getCurrentWindow(); |
23 | 25 | ||
@@ -50,10 +52,16 @@ export default class AppStore extends Store { | |||
50 | 52 | ||
51 | @observable isSystemMuteOverridden = false; | 53 | @observable isSystemMuteOverridden = false; |
52 | 54 | ||
55 | @observable isSystemDarkModeEnabled = false; | ||
56 | |||
53 | @observable isClearingAllCache = false; | 57 | @observable isClearingAllCache = false; |
54 | 58 | ||
55 | @observable isFullScreen = mainWindow.isFullScreen(); | 59 | @observable isFullScreen = mainWindow.isFullScreen(); |
56 | 60 | ||
61 | @observable isFocused = true; | ||
62 | |||
63 | dictionaries = []; | ||
64 | |||
57 | constructor(...args) { | 65 | constructor(...args) { |
58 | super(...args); | 66 | super(...args); |
59 | 67 | ||
@@ -77,7 +85,7 @@ export default class AppStore extends Store { | |||
77 | ]); | 85 | ]); |
78 | } | 86 | } |
79 | 87 | ||
80 | setup() { | 88 | async setup() { |
81 | this._appStartsCounter(); | 89 | this._appStartsCounter(); |
82 | // Focus the active service | 90 | // Focus the active service |
83 | window.addEventListener('focus', this.actions.service.focusActiveService); | 91 | window.addEventListener('focus', this.actions.service.focusActiveService); |
@@ -159,6 +167,14 @@ export default class AppStore extends Store { | |||
159 | this.locale = this._getDefaultLocale(); | 167 | this.locale = this._getDefaultLocale(); |
160 | 168 | ||
161 | this._healthCheck(); | 169 | this._healthCheck(); |
170 | |||
171 | this.isSystemDarkModeEnabled = systemPreferences.isDarkMode(); | ||
172 | |||
173 | onVisibilityChange((isVisible) => { | ||
174 | this.isFocused = isVisible; | ||
175 | |||
176 | debug('Window is visible/focused', isVisible); | ||
177 | }); | ||
162 | } | 178 | } |
163 | 179 | ||
164 | @computed get cacheSize() { | 180 | @computed get cacheSize() { |
@@ -304,31 +320,12 @@ export default class AppStore extends Store { | |||
304 | } | 320 | } |
305 | 321 | ||
306 | _getDefaultLocale() { | 322 | _getDefaultLocale() { |
307 | let locale = app.getLocale(); | 323 | return getLocale({ |
308 | if (locales[locale] === undefined) { | 324 | locale: app.getLocale(), |
309 | let localeFuzzy; | 325 | locales, |
310 | Object.keys(locales).forEach((localStr) => { | 326 | defaultLocale, |
311 | if (locales && Object.hasOwnProperty.call(locales, localStr)) { | 327 | fallbackLocale: DEFAULT_APP_SETTINGS.fallbackLocale, |
312 | if (locale.substring(0, 2) === localStr.substring(0, 2)) { | 328 | }); |
313 | localeFuzzy = localStr; | ||
314 | } | ||
315 | } | ||
316 | }); | ||
317 | |||
318 | if (localeFuzzy !== undefined) { | ||
319 | locale = localeFuzzy; | ||
320 | } | ||
321 | } | ||
322 | |||
323 | if (locales[locale] === undefined) { | ||
324 | locale = defaultLocale; | ||
325 | } | ||
326 | |||
327 | if (!locale) { | ||
328 | locale = DEFAULT_APP_SETTINGS.fallbackLocale; | ||
329 | } | ||
330 | |||
331 | return locale; | ||
332 | } | 329 | } |
333 | 330 | ||
334 | _muteAppHandler() { | 331 | _muteAppHandler() { |