diff options
author | vantezzen <hello@vantezzen.io> | 2019-10-18 20:15:56 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-10-18 20:15:56 +0200 |
commit | d443bca3c82230dd6b9c59d55fbde01a051a6ab5 (patch) | |
tree | 68751f48cc2ed70d0e78a1f5bb102ee9daedd334 /src/stores | |
parent | Fix lint (diff) | |
parent | Fix lint (diff) | |
download | ferdium-app-d443bca3c82230dd6b9c59d55fbde01a051a6ab5.tar.gz ferdium-app-d443bca3c82230dd6b9c59d55fbde01a051a6ab5.tar.zst ferdium-app-d443bca3c82230dd6b9c59d55fbde01a051a6ab5.zip |
Merge branch 'develop' into local-server
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/FeaturesStore.js | 2 | ||||
-rw-r--r-- | src/stores/RecipesStore.js | 2 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 31 |
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'; | |||
20 | import serviceLimit from '../features/serviceLimit'; | 20 | import serviceLimit from '../features/serviceLimit'; |
21 | import communityRecipes from '../features/communityRecipes'; | 21 | import communityRecipes from '../features/communityRecipes'; |
22 | import todos from '../features/todos'; | 22 | import todos from '../features/todos'; |
23 | import accentColor from '../features/accentColor'; | ||
23 | 24 | ||
24 | import { DEFAULT_FEATURES_CONFIG } from '../config'; | 25 | import { 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 @@ | |||
1 | import { shell } from 'electron'; | ||
1 | import { | 2 | import { |
2 | action, | 3 | action, |
3 | reaction, | 4 | reaction, |
@@ -6,12 +7,15 @@ import { | |||
6 | } from 'mobx'; | 7 | } from 'mobx'; |
7 | import { remove } from 'lodash'; | 8 | import { remove } from 'lodash'; |
8 | import ms from 'ms'; | 9 | import ms from 'ms'; |
10 | import fs from 'fs-extra'; | ||
11 | import path from 'path'; | ||
9 | 12 | ||
10 | import Store from './lib/Store'; | 13 | import Store from './lib/Store'; |
11 | import Request from './lib/Request'; | 14 | import Request from './lib/Request'; |
12 | import CachedRequest from './lib/CachedRequest'; | 15 | import CachedRequest from './lib/CachedRequest'; |
13 | import { matchRoute } from '../helpers/routing-helpers'; | 16 | import { matchRoute } from '../helpers/routing-helpers'; |
14 | import { isInTimeframe } from '../helpers/schedule-helpers'; | 17 | import { isInTimeframe } from '../helpers/schedule-helpers'; |
18 | import { getRecipeDirectory, getDevRecipeDirectory } from '../helpers/recipe-helpers'; | ||
15 | import { workspaceStore } from '../features/workspaces'; | 19 | import { workspaceStore } from '../features/workspaces'; |
16 | import { serviceLimitStore } from '../features/serviceLimit'; | 20 | import { serviceLimitStore } from '../features/serviceLimit'; |
17 | import { RESTRICTION_TYPES } from '../models/Service'; | 21 | import { 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); |