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.js52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index 75bb38fe0..8c4cd47eb 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,50 @@ 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 // Disable lock first - otherwise the lock might not get activated corrently
75 this.actions.settings.update({
76 type: 'app',
77 data: {
78 locked: false,
79 },
80 });
81 setTimeout(() => {
82 this.actions.settings.update({
83 type: 'app',
84 data: {
85 locked: true,
86 },
87 });
88 }, 0);
89 }
90 }, 1000);
46 } 91 }
47 92
48 @computed get app() { 93 @computed get app() {
@@ -121,6 +166,7 @@ export default class SettingsStore extends Store {
121 runInBackground: legacySettings.runInBackground, 166 runInBackground: legacySettings.runInBackground,
122 enableSystemTray: legacySettings.enableSystemTray, 167 enableSystemTray: legacySettings.enableSystemTray,
123 minimizeToSystemTray: legacySettings.minimizeToSystemTray, 168 minimizeToSystemTray: legacySettings.minimizeToSystemTray,
169 server: API,
124 isAppMuted: legacySettings.isAppMuted, 170 isAppMuted: legacySettings.isAppMuted,
125 enableGPUAcceleration: legacySettings.enableGPUAcceleration, 171 enableGPUAcceleration: legacySettings.enableGPUAcceleration,
126 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted, 172 showMessageBadgeWhenMuted: legacySettings.showMessageBadgeWhenMuted,