diff options
author | 2021-10-29 05:58:33 +0530 | |
---|---|---|
committer | 2021-10-29 05:58:33 +0530 | |
commit | a956ab9c9f3c571232118babe699709c9e0144d7 (patch) | |
tree | e612be3f6df3ccae0635400c64c1b9ec65b4bd87 /src/webview/recipe.js | |
parent | Update submodules, browserslist data updates and linter fixes [skip ci] (diff) | |
download | ferdium-app-a956ab9c9f3c571232118babe699709c9e0144d7.tar.gz ferdium-app-a956ab9c9f3c571232118babe699709c9e0144d7.tar.zst ferdium-app-a956ab9c9f3c571232118babe699709c9e0144d7.zip |
refactor: Remove duplicate code
Diffstat (limited to 'src/webview/recipe.js')
-rw-r--r-- | src/webview/recipe.js | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 70241419a..0b44d1d01 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -27,6 +27,7 @@ import { DialogTitleHandler } from './dialogTitle'; | |||
27 | import { SessionHandler } from './sessionHandler'; | 27 | import { SessionHandler } from './sessionHandler'; |
28 | import contextMenu from './contextMenu'; | 28 | import contextMenu from './contextMenu'; |
29 | import { | 29 | import { |
30 | darkModeStyleExists, | ||
30 | injectDarkModeStyle, | 31 | injectDarkModeStyle, |
31 | isDarkModeStyleInjected, | 32 | isDarkModeStyleInjected, |
32 | removeDarkModeStyle, | 33 | removeDarkModeStyle, |
@@ -320,15 +321,6 @@ class RecipeController { | |||
320 | ) { | 321 | ) { |
321 | debug('Enable dark mode'); | 322 | debug('Enable dark mode'); |
322 | 323 | ||
323 | // Check if recipe has a darkmode.css | ||
324 | const darkModeStyle = join( | ||
325 | this.settings.service.recipe.path, | ||
326 | 'darkmode.css', | ||
327 | ); | ||
328 | const darkModeExists = pathExistsSync(darkModeStyle); | ||
329 | |||
330 | debug('darkmode.css exists? ', darkModeExists); | ||
331 | |||
332 | // Check if recipe has a custom dark mode handler | 324 | // Check if recipe has a custom dark mode handler |
333 | if (this.recipe && this.recipe.darkModeHandler) { | 325 | if (this.recipe && this.recipe.darkModeHandler) { |
334 | debug('Using custom dark mode handler'); | 326 | debug('Using custom dark mode handler'); |
@@ -341,8 +333,8 @@ class RecipeController { | |||
341 | } | 333 | } |
342 | 334 | ||
343 | this.recipe.darkModeHandler(true, handlerConfig); | 335 | this.recipe.darkModeHandler(true, handlerConfig); |
344 | } else if (darkModeExists) { | 336 | } else if (darkModeStyleExists(this.settings.service.recipe.path)) { |
345 | debug('Injecting darkmode.css'); | 337 | debug('Injecting darkmode from recipe'); |
346 | injectDarkModeStyle(this.settings.service.recipe.path); | 338 | injectDarkModeStyle(this.settings.service.recipe.path); |
347 | 339 | ||
348 | // Make sure universal dark mode is disabled | 340 | // Make sure universal dark mode is disabled |
@@ -379,7 +371,7 @@ class RecipeController { | |||
379 | 371 | ||
380 | this.recipe.darkModeHandler(false, handlerConfig); | 372 | this.recipe.darkModeHandler(false, handlerConfig); |
381 | } else if (isDarkModeStyleInjected()) { | 373 | } else if (isDarkModeStyleInjected()) { |
382 | debug('Removing injected darkmode.css'); | 374 | debug('Removing injected darkmode from recipe'); |
383 | removeDarkModeStyle(); | 375 | removeDarkModeStyle(); |
384 | } else { | 376 | } else { |
385 | debug('Removing Dark Reader'); | 377 | debug('Removing Dark Reader'); |