diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/recipe.js | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e00566283..fca00fde2 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 | ||