aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/SettingsStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/SettingsStore.js')
-rw-r--r--src/stores/SettingsStore.js43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index 75bb38fe0..c09f24af7 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,17 +1,18 @@
1import { ipcRenderer } from 'electron'; 1import { ipcRenderer, remote } from 'electron';
2import { 2import {
3 action, computed, observable, 3 action, computed, observable, reaction,
4} from 'mobx'; 4} from 'mobx';
5import localStorage from 'mobx-localstorage'; 5import localStorage from 'mobx-localstorage';
6 6
7import Store from './lib/Store'; 7import Store from './lib/Store';
8import Request from './lib/Request'; 8import Request from './lib/Request';
9import { getLocale } from '../helpers/i18n-helpers'; 9import { getLocale } from '../helpers/i18n-helpers';
10import { API } from '../environment';
10 11
11import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config'; 12import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config';
12import { SPELLCHECKER_LOCALES } from '../i18n/languages'; 13import { SPELLCHECKER_LOCALES } from '../i18n/languages';
13 14
14const debug = require('debug')('Franz:SettingsStore'); 15const debug = require('debug')('Ferdi:SettingsStore');
15 16
16export default class SettingsStore extends Store { 17export default class SettingsStore extends Store {
17 @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings'); 18 @observable updateAppSettingsRequest = new Request(this.api.local, 'updateAppSettings');
@@ -43,6 +44,41 @@ export default class SettingsStore extends Store {
43 44
44 async setup() { 45 async setup() {
45 await this._migrate(); 46 await this._migrate();
47
48 reaction(
49 () => this.all.app.autohideMenuBar,
50 () => remote.getCurrentWindow().setAutoHideMenuBar(
51 this.all.app.autohideMenuBar,
52 ),
53 );
54
55 reaction(
56 () => this.all.app.locked,
57 () => {
58 const { router } = window.ferdi.stores;
59
60 if (this.all.app.locked && this.all.app.lockingFeatureEnabled) {
61 // App just got locked, redirect to unlock screen
62 router.push('/auth/locked');
63 } else if (router.location.pathname.includes('/auth/locked')) {
64 // App is unlocked but user is still on locked screen
65 // Redirect to homepage
66 router.push('/');
67 }
68 },
69 );
70
71 // Make sure to lock app on launch if locking feature is enabled
72 setTimeout(() => {
73 if (this.all.app.lockingFeatureEnabled) {
74 this.actions.settings.update({
75 type: 'app',
76 data: {
77 locked: true,
78 },
79 });
80 }
81 }, 1000);
46 } 82 }
47 83
48 @computed get app() { 84 @computed get app() {
@@ -121,6 +157,7 @@ export default class SettingsStore extends Store {
121 runInBackground: legacySettings.runInBackground, 157 runInBackground: legacySettings.runInBackground,
122 enableSystemTray: legacySettings.enableSystemTray, 158 enableSystemTray: legacySettings.enableSystemTray,
123 minimizeToSystemTray: legacySettings.minimizeToSystemTray, 159 minimizeToSystemTray: legacySettings.minimizeToSystemTray,
160 server: API,
124 isAppMuted: legacySettings.isAppMuted, 161 isAppMuted: legacySettings.isAppMuted,
125 enableGPUAcceleration: legacySettings.enableGPUAcceleration, 162 enableGPUAcceleration: legacySettings.enableGPUAcceleration,
126 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted, 163 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted,