diff options
author | 2019-09-23 20:15:23 +0200 | |
---|---|---|
committer | 2019-09-23 20:15:23 +0200 | |
commit | 1eb148d121dbcbe1e54085a9fb897fe7ac1529b7 (patch) | |
tree | 14d70b0957ab1ea7ae7ff6df1f4b387ab35175d3 /src | |
parent | Setup repo-sync workflow (diff) | |
download | ferdium-app-1eb148d121dbcbe1e54085a9fb897fe7ac1529b7.tar.gz ferdium-app-1eb148d121dbcbe1e54085a9fb897fe7ac1529b7.tar.zst ferdium-app-1eb148d121dbcbe1e54085a9fb897fe7ac1529b7.zip |
Add darkreader for universal darkmode
Diffstat (limited to 'src')
-rw-r--r-- | src/stores/ServicesStore.js | 5 | ||||
-rw-r--r-- | src/webview/recipe.js | 28 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 45350d8f5..3173004d4 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -96,6 +96,11 @@ export default class ServicesStore extends Store { | |||
96 | () => this.stores.settings.app.spellcheckerLanguage, | 96 | () => this.stores.settings.app.spellcheckerLanguage, |
97 | () => this._shareSettingsWithServiceProcess(), | 97 | () => this._shareSettingsWithServiceProcess(), |
98 | ); | 98 | ); |
99 | |||
100 | reaction( | ||
101 | () => this.stores.settings.app.darkMode, | ||
102 | () => this._shareSettingsWithServiceProcess(), | ||
103 | ); | ||
99 | } | 104 | } |
100 | 105 | ||
101 | @computed get all() { | 106 | @computed get all() { |
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e00566283..e97013b3c 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -1,8 +1,13 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import { autorun, computed, observable } from 'mobx'; | 3 | import { autorun, computed, observable } from 'mobx'; |
4 | import fs from 'fs-extra'; | ||
4 | import { loadModule } from 'cld3-asm'; | 5 | import { loadModule } from 'cld3-asm'; |
5 | import { debounce } from 'lodash'; | 6 | import { debounce } from 'lodash'; |
7 | import { | ||
8 | enable as enableDarkMode, | ||
9 | disable as disableDarkMode, | ||
10 | } from 'darkreader'; | ||
6 | 11 | ||
7 | import RecipeWebview from './lib/RecipeWebview'; | 12 | import RecipeWebview from './lib/RecipeWebview'; |
8 | 13 | ||
@@ -109,12 +114,27 @@ class RecipeController { | |||
109 | } | 114 | } |
110 | } | 115 | } |
111 | 116 | ||
112 | if (this.settings.service.isDarkModeEnabled) { | 117 | if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { |
113 | debug('Enable dark mode'); | 118 | debug('Enable dark mode'); |
114 | injectDarkModeStyle(this.settings.service.recipe.path); | 119 | |
115 | } else if (isDarkModeStyleInjected()) { | 120 | // Check if recipe has a darkmode.css |
121 | const darkModeStyle = path.join(this.settings.service.recipe.path, 'darkmode.css'); | ||
122 | const darkModeExists = fs.pathExistsSync(darkModeStyle); | ||
123 | |||
124 | if (darkModeExists) { | ||
125 | injectDarkModeStyle(this.settings.service.recipe.path); | ||
126 | } else { | ||
127 | // Use darkreader instead | ||
128 | enableDarkMode(); | ||
129 | } | ||
130 | } else { | ||
116 | debug('Remove dark mode'); | 131 | debug('Remove dark mode'); |
117 | removeDarkModeStyle(); | 132 | |
133 | if (isDarkModeStyleInjected()) { | ||
134 | removeDarkModeStyle(); | ||
135 | } else { | ||
136 | disableDarkMode(); | ||
137 | } | ||
118 | } | 138 | } |
119 | } | 139 | } |
120 | 140 | ||