aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/FeaturesStore.js2
-rw-r--r--src/stores/RecipesStore.js2
-rw-r--r--src/stores/ServicesStore.js31
3 files changed, 34 insertions, 1 deletions
diff --git a/src/stores/FeaturesStore.js b/src/stores/FeaturesStore.js
index c39b6d7f3..3d9542245 100644
--- a/src/stores/FeaturesStore.js
+++ b/src/stores/FeaturesStore.js
@@ -20,6 +20,7 @@ import settingsWS from '../features/settingsWS';
20import serviceLimit from '../features/serviceLimit'; 20import serviceLimit from '../features/serviceLimit';
21import communityRecipes from '../features/communityRecipes'; 21import communityRecipes from '../features/communityRecipes';
22import todos from '../features/todos'; 22import todos from '../features/todos';
23import accentColor from '../features/accentColor';
23 24
24import { DEFAULT_FEATURES_CONFIG } from '../config'; 25import { DEFAULT_FEATURES_CONFIG } from '../config';
25 26
@@ -83,5 +84,6 @@ export default class FeaturesStore extends Store {
83 serviceLimit(this.stores, this.actions); 84 serviceLimit(this.stores, this.actions);
84 communityRecipes(this.stores, this.actions); 85 communityRecipes(this.stores, this.actions);
85 todos(this.stores, this.actions); 86 todos(this.stores, this.actions);
87 accentColor(this.stores, this.actions);
86 } 88 }
87} 89}
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js
index 7f91049df..8b2bde5df 100644
--- a/src/stores/RecipesStore.js
+++ b/src/stores/RecipesStore.js
@@ -108,7 +108,7 @@ export default class RecipesStore extends Store {
108 async _checkIfRecipeIsInstalled() { 108 async _checkIfRecipeIsInstalled() {
109 const { router } = this.stores; 109 const { router } = this.stores;
110 110
111 const match = matchRoute('/settings/services/add/:id', router.location.pathname); 111 const match = router.location && matchRoute('/settings/services/add/:id', router.location.pathname);
112 if (match) { 112 if (match) {
113 const recipeId = match.id; 113 const recipeId = match.id;
114 114
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 1bf32af9f..185a6f0ae 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -1,3 +1,4 @@
1import { shell } from 'electron';
1import { 2import {
2 action, 3 action,
3 reaction, 4 reaction,
@@ -6,12 +7,15 @@ import {
6} from 'mobx'; 7} from 'mobx';
7import { remove } from 'lodash'; 8import { remove } from 'lodash';
8import ms from 'ms'; 9import ms from 'ms';
10import fs from 'fs-extra';
11import path from 'path';
9 12
10import Store from './lib/Store'; 13import Store from './lib/Store';
11import Request from './lib/Request'; 14import Request from './lib/Request';
12import CachedRequest from './lib/CachedRequest'; 15import CachedRequest from './lib/CachedRequest';
13import { matchRoute } from '../helpers/routing-helpers'; 16import { matchRoute } from '../helpers/routing-helpers';
14import { isInTimeframe } from '../helpers/schedule-helpers'; 17import { isInTimeframe } from '../helpers/schedule-helpers';
18import { getRecipeDirectory, getDevRecipeDirectory } from '../helpers/recipe-helpers';
15import { workspaceStore } from '../features/workspaces'; 19import { workspaceStore } from '../features/workspaces';
16import { serviceLimitStore } from '../features/serviceLimit'; 20import { serviceLimitStore } from '../features/serviceLimit';
17import { RESTRICTION_TYPES } from '../models/Service'; 21import { RESTRICTION_TYPES } from '../models/Service';
@@ -52,6 +56,7 @@ export default class ServicesStore extends Store {
52 this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this)); 56 this.actions.service.createFromLegacyService.listen(this._createFromLegacyService.bind(this));
53 this.actions.service.updateService.listen(this._updateService.bind(this)); 57 this.actions.service.updateService.listen(this._updateService.bind(this));
54 this.actions.service.deleteService.listen(this._deleteService.bind(this)); 58 this.actions.service.deleteService.listen(this._deleteService.bind(this));
59 this.actions.service.openDarkmodeCss.listen(this._openDarkmodeCss.bind(this));
55 this.actions.service.clearCache.listen(this._clearCache.bind(this)); 60 this.actions.service.clearCache.listen(this._clearCache.bind(this));
56 this.actions.service.setWebviewReference.listen(this._setWebviewReference.bind(this)); 61 this.actions.service.setWebviewReference.listen(this._setWebviewReference.bind(this));
57 this.actions.service.detachService.listen(this._detachService.bind(this)); 62 this.actions.service.detachService.listen(this._detachService.bind(this));
@@ -107,6 +112,11 @@ export default class ServicesStore extends Store {
107 () => this.stores.settings.app.darkMode, 112 () => this.stores.settings.app.darkMode,
108 () => this._shareSettingsWithServiceProcess(), 113 () => this._shareSettingsWithServiceProcess(),
109 ); 114 );
115
116 reaction(
117 () => this.stores.settings.app.universalDarkMode,
118 () => this._shareSettingsWithServiceProcess(),
119 );
110 } 120 }
111 121
112 @computed get all() { 122 @computed get all() {
@@ -316,6 +326,27 @@ export default class ServicesStore extends Store {
316 this.actionStatus = request.result.status; 326 this.actionStatus = request.result.status;
317 } 327 }
318 328
329 @action async _openDarkmodeCss({ recipe }) {
330 // Get directory for recipe
331 const normalDirectory = getRecipeDirectory(recipe);
332 const devDirectory = getDevRecipeDirectory(recipe);
333 let directory;
334
335 if (await fs.pathExists(normalDirectory)) {
336 directory = normalDirectory;
337 } else if (await fs.pathExists(devDirectory)) {
338 directory = devDirectory;
339 } else {
340 // Recipe cannot be found on drive
341 return;
342 }
343
344 // Create and open darkmode.css
345 const file = path.join(directory, 'darkmode.css');
346 await fs.ensureFile(file);
347 shell.showItemInFolder(file);
348 }
349
319 @action async _clearCache({ serviceId }) { 350 @action async _clearCache({ serviceId }) {
320 this.clearCacheRequest.reset(); 351 this.clearCacheRequest.reset();
321 const request = this.clearCacheRequest.execute(serviceId); 352 const request = this.clearCacheRequest.execute(serviceId);