aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/AppStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/AppStore.js')
-rw-r--r--src/stores/AppStore.js53
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';
12import { isMac, isLinux, isWindows } from '../environment'; 12import { isMac, isLinux, isWindows } from '../environment';
13import locales from '../i18n/translations'; 13import locales from '../i18n/translations';
14import { gaEvent } from '../lib/analytics'; 14import { gaEvent } from '../lib/analytics';
15import { onVisibilityChange } from '../helpers/visibility-helper';
16import { getLocale } from '../helpers/i18n-helpers';
15 17
16import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; 18import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js';
17 19
18const debug = require('debug')('AppStore'); 20const debug = require('debug')('Franz:AppStore');
19 21
20const { app } = remote; 22const { app, systemPreferences } = remote;
21 23
22const mainWindow = remote.getCurrentWindow(); 24const 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() {