aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-11-19 16:05:00 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-11-19 16:05:00 +0100
commit5551cd9650afb48a1789ed36dffbe4df64e75e5b (patch)
tree5062736ac1ca89824adde9a82380d715a2030fba /src/stores
parentMerge branch 'develop' of github.com:meetfranz/franz into develop (diff)
parentBring package-lock in sync (diff)
downloadferdium-app-5551cd9650afb48a1789ed36dffbe4df64e75e5b.tar.gz
ferdium-app-5551cd9650afb48a1789ed36dffbe4df64e75e5b.tar.zst
ferdium-app-5551cd9650afb48a1789ed36dffbe4df64e75e5b.zip
Merge branch 'feature/dark-theme' into develop
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js6
-rw-r--r--src/stores/SettingsStore.js27
2 files changed, 30 insertions, 3 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 38edff1b4..76d9bfa53 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -17,7 +17,7 @@ import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '..
17 17
18const debug = require('debug')('AppStore'); 18const debug = require('debug')('AppStore');
19 19
20const { app } = remote; 20const { app, systemPreferences } = remote;
21 21
22const mainWindow = remote.getCurrentWindow(); 22const mainWindow = remote.getCurrentWindow();
23 23
@@ -50,6 +50,8 @@ export default class AppStore extends Store {
50 50
51 @observable isSystemMuteOverridden = false; 51 @observable isSystemMuteOverridden = false;
52 52
53 @observable isSystemDarkModeEnabled = false;
54
53 @observable isClearingAllCache = false; 55 @observable isClearingAllCache = false;
54 56
55 @observable isFullScreen = mainWindow.isFullScreen(); 57 @observable isFullScreen = mainWindow.isFullScreen();
@@ -159,6 +161,8 @@ export default class AppStore extends Store {
159 this.locale = this._getDefaultLocale(); 161 this.locale = this._getDefaultLocale();
160 162
161 this._healthCheck(); 163 this._healthCheck();
164
165 this.isSystemDarkModeEnabled = systemPreferences.isDarkMode();
162 } 166 }
163 167
164 @computed get cacheSize() { 168 @computed get cacheSize() {
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js
index 9270a6481..4b5715628 100644
--- a/src/stores/SettingsStore.js
+++ b/src/stores/SettingsStore.js
@@ -1,3 +1,4 @@
1import { remote } from 'electron';
1import { action, computed, observable } from 'mobx'; 2import { action, computed, observable } from 'mobx';
2import localStorage from 'mobx-localstorage'; 3import localStorage from 'mobx-localstorage';
3 4
@@ -6,6 +7,7 @@ import SettingsModel from '../models/Settings';
6import Request from './lib/Request'; 7import Request from './lib/Request';
7import CachedRequest from './lib/CachedRequest'; 8import CachedRequest from './lib/CachedRequest';
8 9
10const { systemPreferences } = remote;
9const debug = require('debug')('SettingsStore'); 11const debug = require('debug')('SettingsStore');
10 12
11export default class SettingsStore extends Store { 13export default class SettingsStore extends Store {
@@ -23,7 +25,7 @@ export default class SettingsStore extends Store {
23 async setup() { 25 async setup() {
24 // We need to wait until `appSettingsRequest` has been executed once, otherwise we can't patch the result. If we don't wait we'd run into an issue with mobx not reacting to changes of previously not existing keys 26 // We need to wait until `appSettingsRequest` has been executed once, otherwise we can't patch the result. If we don't wait we'd run into an issue with mobx not reacting to changes of previously not existing keys
25 await this.appSettingsRequest._promise; 27 await this.appSettingsRequest._promise;
26 this._migrate(); 28 await this._migrate();
27 } 29 }
28 30
29 @computed get all() { 31 @computed get all() {
@@ -67,7 +69,7 @@ export default class SettingsStore extends Store {
67 } 69 }
68 70
69 // Helper 71 // Helper
70 _migrate() { 72 async _migrate() {
71 const legacySettings = localStorage.getItem('app') || {}; 73 const legacySettings = localStorage.getItem('app') || {};
72 74
73 if (!this.all.migration['5.0.0-beta.17-settings']) { 75 if (!this.all.migration['5.0.0-beta.17-settings']) {
@@ -104,5 +106,26 @@ export default class SettingsStore extends Store {
104 106
105 debug('Migrated settings to split stores'); 107 debug('Migrated settings to split stores');
106 } 108 }
109
110 // Enable dark mode once
111 if (!this.all.migration['5.0.0-beta.19-settings']) {
112 this.actions.settings.update({
113 type: 'app',
114 data: {
115 darkMode: systemPreferences.isDarkMode(),
116 },
117 });
118
119 this.actions.settings.update({
120 type: 'migration',
121 data: {
122 '5.0.0-beta.19-settings': true,
123 },
124 });
125
126 localStorage.removeItem('app');
127
128 debug('Set up dark mode');
129 }
107 } 130 }
108} 131}