aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/RecipesStore.js29
-rw-r--r--src/stores/ServicesStore.js6
-rw-r--r--src/stores/UIStore.js2
3 files changed, 34 insertions, 3 deletions
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js
index 8b2bde5df..cf5d0a074 100644
--- a/src/stores/RecipesStore.js
+++ b/src/stores/RecipesStore.js
@@ -1,9 +1,13 @@
1import { action, computed, observable } from 'mobx'; 1import { action, computed, observable } from 'mobx';
2import fs from 'fs-extra';
3import path from 'path';
4import semver from 'semver';
2 5
3import Store from './lib/Store'; 6import Store from './lib/Store';
4import CachedRequest from './lib/CachedRequest'; 7import CachedRequest from './lib/CachedRequest';
5import Request from './lib/Request'; 8import Request from './lib/Request';
6import { matchRoute } from '../helpers/routing-helpers'; 9import { matchRoute } from '../helpers/routing-helpers';
10import { RECIPES_PATH } from '../config';
7 11
8const debug = require('debug')('Ferdi:RecipeStore'); 12const debug = require('debug')('Ferdi:RecipeStore');
9 13
@@ -83,7 +87,30 @@ export default class RecipesStore extends Store {
83 87
84 if (Object.keys(recipes).length === 0) return; 88 if (Object.keys(recipes).length === 0) return;
85 89
86 const updates = await this.getRecipeUpdatesRequest.execute(recipes)._promise; 90 const remoteUpdates = await this.getRecipeUpdatesRequest.execute(recipes)._promise;
91
92 // Check for local updates
93 const allJsonFile = path.join(RECIPES_PATH, 'all.json');
94 const allJson = await fs.readJSON(allJsonFile);
95 const localUpdates = [];
96
97 Object.keys(recipes).forEach((recipe) => {
98 const version = recipes[recipe];
99
100 // Find recipe in local recipe repository
101 const localRecipe = allJson.find(r => r.id === recipe);
102
103 if (localRecipe && semver.lt(version, localRecipe.version)) {
104 localUpdates.push(recipe);
105 }
106 });
107
108 const updates = [
109 ...remoteUpdates,
110 ...localUpdates,
111 ];
112 debug('Got update information (local, remote):', localUpdates, remoteUpdates);
113
87 const length = updates.length - 1; 114 const length = updates.length - 1;
88 const syncUpdate = async (i) => { 115 const syncUpdate = async (i) => {
89 const update = updates[i]; 116 const update = updates[i];
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 3dd601bc3..fda18b514 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -83,6 +83,7 @@ export default class ServicesStore extends Store {
83 this.actions.service.openDevTools.listen(this._openDevTools.bind(this)); 83 this.actions.service.openDevTools.listen(this._openDevTools.bind(this));
84 this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this)); 84 this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this));
85 this.actions.service.setHibernation.listen(this._setHibernation.bind(this)); 85 this.actions.service.setHibernation.listen(this._setHibernation.bind(this));
86 this.actions.service.shareSettingsWithServiceProcess.listen(this._shareSettingsWithServiceProcess.bind(this));
86 87
87 this.registerReactions([ 88 this.registerReactions([
88 this._focusServiceReaction.bind(this), 89 this._focusServiceReaction.bind(this),
@@ -771,7 +772,10 @@ export default class ServicesStore extends Store {
771 } 772 }
772 773
773 _shareSettingsWithServiceProcess() { 774 _shareSettingsWithServiceProcess() {
774 const settings = this.stores.settings.app; 775 const settings = {
776 ...this.stores.settings.app,
777 isDarkThemeActive: this.stores.ui.isDarkThemeActive,
778 };
775 this.actions.service.sendIPCMessageToAllServices({ 779 this.actions.service.sendIPCMessageToAllServices({
776 channel: 'settings-update', 780 channel: 'settings-update',
777 args: settings, 781 args: settings,
diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js
index 7e6f89fed..6941cf086 100644
--- a/src/stores/UIStore.js
+++ b/src/stores/UIStore.js
@@ -32,6 +32,7 @@ export default class UIStore extends Store {
32 'AppleInterfaceThemeChangedNotification', 32 'AppleInterfaceThemeChangedNotification',
33 () => { 33 () => {
34 this.isOsDarkThemeActive = nativeTheme.shouldUseDarkColors; 34 this.isOsDarkThemeActive = nativeTheme.shouldUseDarkColors;
35 this.actions.service.shareSettingsWithServiceProcess();
35 }, 36 },
36 ); 37 );
37 } 38 }
@@ -56,7 +57,6 @@ export default class UIStore extends Store {
56 57
57 @computed get isDarkThemeActive() { 58 @computed get isDarkThemeActive() {
58 const isMacWithAdaptableInDarkMode = isMac 59 const isMacWithAdaptableInDarkMode = isMac
59 && this.stores.settings.all.app.darkMode
60 && this.stores.settings.all.app.adaptableDarkMode 60 && this.stores.settings.all.app.adaptableDarkMode
61 && this.isOsDarkThemeActive; 61 && this.isOsDarkThemeActive;
62 const isMacWithoutAdaptableInDarkMode = isMac 62 const isMacWithoutAdaptableInDarkMode = isMac