From 5714e2fbae7d8b6f69adc3ae064cded2bb8c35d7 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Fri, 31 Jan 2020 16:44:56 +0100 Subject: Add better sync between Ferdi and service dark mode --- src/actions/service.js | 1 + src/stores/ServicesStore.js | 6 +++++- src/stores/UIStore.js | 1 + src/webview/recipe.js | 9 +++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/actions/service.js b/src/actions/service.js index 3283d8fee..d32bb80d3 100644 --- a/src/actions/service.js +++ b/src/actions/service.js @@ -98,4 +98,5 @@ export default { serviceId: PropTypes.string.isRequired, hibernating: PropTypes.bool.isRequired, }, + shareSettingsWithServiceProcess: {}, }; diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 3dd601bc3..731305141 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -83,6 +83,7 @@ export default class ServicesStore extends Store { this.actions.service.openDevTools.listen(this._openDevTools.bind(this)); this.actions.service.openDevToolsForActiveService.listen(this._openDevToolsForActiveService.bind(this)); this.actions.service.setHibernation.listen(this._setHibernation.bind(this)); + this.actions.service.shareSettingsWithServiceProcess.listen(this._shareSettingsWithServiceProcess.bind(this)); this.registerReactions([ this._focusServiceReaction.bind(this), @@ -771,7 +772,10 @@ export default class ServicesStore extends Store { } _shareSettingsWithServiceProcess() { - const settings = this.stores.settings.app; + const settings = { + ...this.stores.settings.app, + isDarkThemeActive: this.stores.ui.isDarkThemeActive + }; this.actions.service.sendIPCMessageToAllServices({ channel: 'settings-update', args: settings, diff --git a/src/stores/UIStore.js b/src/stores/UIStore.js index 7e6f89fed..5b9672798 100644 --- a/src/stores/UIStore.js +++ b/src/stores/UIStore.js @@ -32,6 +32,7 @@ export default class UIStore extends Store { 'AppleInterfaceThemeChangedNotification', () => { this.isOsDarkThemeActive = nativeTheme.shouldUseDarkColors; + this.actions.service.shareSettingsWithServiceProcess(); }, ); } diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 8ea2fabd9..4e2f5233a 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -127,8 +127,13 @@ class RecipeController { } } - console.log('Set theme to: ', this.settings.service.isDarkModeEnabled ? 'Dark' : 'Light'); - if (this.settings.service.isDarkModeEnabled) { + console.log( + 'Darkmode enabled?', + this.settings.service.isDarkModeEnabled, + 'Dark theme active?', + this.settings.app.isDarkThemeActive + ); + if (this.settings.service.isDarkModeEnabled && this.settings.app.isDarkThemeActive !== false) { debug('Enable dark mode'); // Check if recipe has a darkmode.css -- cgit v1.2.3-54-g00ecf