aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/AppStore.js27
-rw-r--r--src/stores/UIStore.js30
-rw-r--r--src/stores/lib/Reaction.js6
3 files changed, 55 insertions, 8 deletions
diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js
index 72c4b4d0b..2ac306a2a 100644
--- a/src/stores/AppStore.js
+++ b/src/stores/AppStore.js
@@ -8,6 +8,9 @@ import AutoLaunch from 'auto-launch';
8import prettyBytes from 'pretty-bytes'; 8import prettyBytes from 'pretty-bytes';
9import ms from 'ms'; 9import ms from 'ms';
10import { URL } from 'url'; 10import { URL } from 'url';
11import os from 'os';
12import path from 'path';
13import { readJsonSync } from 'fs-extra';
11 14
12import Store from './lib/Store'; 15import Store from './lib/Store';
13import Request from './lib/Request'; 16import Request from './lib/Request';
@@ -23,7 +26,7 @@ import { isValidExternalURL } from '../helpers/url-helpers';
23 26
24const debug = require('debug')('Franz:AppStore'); 27const debug = require('debug')('Franz:AppStore');
25 28
26const { app, systemPreferences } = remote; 29const { app, systemPreferences, screen } = remote;
27 30
28const mainWindow = remote.getCurrentWindow(); 31const mainWindow = remote.getCurrentWindow();
29 32
@@ -182,6 +185,26 @@ export default class AppStore extends Store {
182 return prettyBytes(this.getAppCacheSizeRequest.execute().result || 0); 185 return prettyBytes(this.getAppCacheSizeRequest.execute().result || 0);
183 } 186 }
184 187
188 @computed get debugInfo() {
189 return {
190 host: {
191 platform: process.platform,
192 release: os.release(),
193 screens: screen.getAllDisplays(),
194 },
195 franz: {
196 version: app.getVersion(),
197 electron: process.versions.electron,
198 installedRecipes: this.stores.recipes.all.map(recipe => ({ id: recipe.id, version: recipe.version })),
199 devRecipes: this.stores.recipePreviews.dev.map(recipe => ({ id: recipe.id, version: recipe.version })),
200 services: this.stores.services.all.map(service => ({ id: service.id, recipe: service.recipe.id })),
201 workspaces: this.stores.workspaces.workspaces.map(workspace => ({ id: workspace.id, services: workspace.services })),
202 windowSettings: readJsonSync(path.join(app.getPath('userData'), 'window-state.json')),
203 user: this.stores.user.data.id,
204 },
205 };
206 }
207
185 // Actions 208 // Actions
186 @action _notify({ 209 @action _notify({
187 title, options, notificationId, serviceId = null, 210 title, options, notificationId, serviceId = null,
@@ -189,7 +212,7 @@ export default class AppStore extends Store {
189 if (this.stores.settings.all.app.isAppMuted) return; 212 if (this.stores.settings.all.app.isAppMuted) return;
190 213
191 // TODO: is there a simple way to use blobs for notifications without storing them on disk? 214 // TODO: is there a simple way to use blobs for notifications without storing them on disk?
192 if (options.icon.startsWith('blob:')) { 215 if (options.icon && options.icon.startsWith('blob:')) {
193 delete options.icon; 216 delete options.icon;
194 } 217 }
195 218
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js
index a95a8e1e0..9680c5bcc 100644
--- a/src/stores/UIStore.js
+++ b/src/stores/UIStore.js
@@ -1,4 +1,9 @@
1import { action, observable, computed } from 'mobx'; 1import {
2 action,
3 observable,
4 computed,
5 reaction,
6} from 'mobx';
2import { theme } from '@meetfranz/theme'; 7import { theme } from '@meetfranz/theme';
3 8
4import Store from './lib/Store'; 9import Store from './lib/Store';
@@ -15,10 +20,18 @@ export default class UIStore extends Store {
15 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this)); 20 this.actions.ui.toggleServiceUpdatedInfoBar.listen(this._toggleServiceUpdatedInfoBar.bind(this));
16 } 21 }
17 22
23 setup() {
24 reaction(
25 () => this.isDarkThemeActive,
26 () => this._setupThemeInDOM(),
27 { fireImmediately: true },
28 );
29 }
30
18 @computed get showMessageBadgesEvenWhenMuted() { 31 @computed get showMessageBadgesEvenWhenMuted() {
19 const settings = this.stores.settings.all; 32 const settings = this.stores.settings.all;
20 33
21 return (settings.app.isAppMuted && settings.app.showMessageBadgeWhenMuted) || !settings.isAppMuted; 34 return (settings.app.isAppMuted && settings.app.showMessageBadgeWhenMuted) || !settings.app.isAppMuted;
22 } 35 }
23 36
24 @computed get isDarkThemeActive() { 37 @computed get isDarkThemeActive() {
@@ -26,7 +39,7 @@ export default class UIStore extends Store {
26 } 39 }
27 40
28 @computed get theme() { 41 @computed get theme() {
29 if (this.isDarkThemeActive) return theme('dark'); 42 if (this.isDarkThemeActive || this.stores.settings.app.darkMode) return theme('dark');
30 return theme('default'); 43 return theme('default');
31 } 44 }
32 45
@@ -47,4 +60,15 @@ export default class UIStore extends Store {
47 } 60 }
48 this.showServicesUpdatedInfoBar = visibility; 61 this.showServicesUpdatedInfoBar = visibility;
49 } 62 }
63
64 // Reactions
65 _setupThemeInDOM() {
66 const body = document.querySelector('body');
67
68 if (!this.isDarkThemeActive) {
69 body.classList.remove('theme__dark');
70 } else {
71 body.classList.add('theme__dark');
72 }
73 }
50} 74}
diff --git a/src/stores/lib/Reaction.js b/src/stores/lib/Reaction.js
index f2642908f..f8009b7f6 100644
--- a/src/stores/lib/Reaction.js
+++ b/src/stores/lib/Reaction.js
@@ -13,15 +13,15 @@ export default class Reaction {
13 13
14 start() { 14 start() {
15 if (!this.isRunning) { 15 if (!this.isRunning) {
16 this.dispose = autorun(() => this.reaction()); 16 this.dispose = autorun(this.reaction);
17 this.isActive = true; 17 this.isRunning = true;
18 } 18 }
19 } 19 }
20 20
21 stop() { 21 stop() {
22 if (this.isRunning) { 22 if (this.isRunning) {
23 this.dispose(); 23 this.dispose();
24 this.isActive = false; 24 this.isRunning = false;
25 } 25 }
26 } 26 }
27} 27}