aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/recipe.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/webview/recipe.ts')
-rw-r--r--src/webview/recipe.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/webview/recipe.ts b/src/webview/recipe.ts
index 0d18e4347..76615d234 100644
--- a/src/webview/recipe.ts
+++ b/src/webview/recipe.ts
@@ -1,6 +1,6 @@
1/* eslint-disable global-require */ 1/* eslint-disable global-require */
2/* eslint-disable import/no-dynamic-require */ 2/* eslint-disable import/no-dynamic-require */
3/* eslint-disable import/first */ 3
4import { noop, debounce } from 'lodash'; 4import { noop, debounce } from 'lodash';
5import { contextBridge, ipcRenderer } from 'electron'; 5import { contextBridge, ipcRenderer } from 'electron';
6import { join } from 'path'; 6import { join } from 'path';
@@ -52,7 +52,7 @@ import Service from '../models/Service';
52// This will cause the service to fail loading 52// This will cause the service to fail loading
53// As the message API is not actually needed, we'll add this shim sendMessage 53// As the message API is not actually needed, we'll add this shim sendMessage
54// function in order for darkreader to continue working 54// function in order for darkreader to continue working
55// @ts-ignore 55// @ts-expect-error Fix this
56window.chrome.runtime.sendMessage = noop; 56window.chrome.runtime.sendMessage = noop;
57 57
58const debug = require('../preload-safe-debug')('Ferdium:Plugin'); 58const debug = require('../preload-safe-debug')('Ferdium:Plugin');
@@ -143,9 +143,9 @@ class RecipeController {
143 service: Service; 143 service: Service;
144 } = { 144 } = {
145 overrideSpellcheckerLanguage: false, 145 overrideSpellcheckerLanguage: false,
146 // @ts-ignore 146 // @ts-expect-error Fix this
147 app: DEFAULT_APP_SETTINGS, 147 app: DEFAULT_APP_SETTINGS,
148 // @ts-ignore 148 // @ts-expect-error Fix this
149 service: { 149 service: {
150 isDarkModeEnabled: false, 150 isDarkModeEnabled: false,
151 spellcheckerLanguage: '', 151 spellcheckerLanguage: '',
@@ -233,6 +233,7 @@ class RecipeController {
233 const modulePath = join(recipe.path, 'webview.js'); 233 const modulePath = join(recipe.path, 'webview.js');
234 debug('module path', modulePath); 234 debug('module path', modulePath);
235 // Delete module from cache 235 // Delete module from cache
236 // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
236 delete require.cache[require.resolve(modulePath)]; 237 delete require.cache[require.resolve(modulePath)];
237 try { 238 try {
238 this.recipe = new RecipeWebview( 239 this.recipe = new RecipeWebview(
@@ -311,7 +312,7 @@ class RecipeController {
311 debug('translatorEngine', this.settings.app.translatorEngine); 312 debug('translatorEngine', this.settings.app.translatorEngine);
312 debug('translatorLanguage', this.settings.app.translatorLanguage); 313 debug('translatorLanguage', this.settings.app.translatorLanguage);
313 314
314 if (this.userscript && this.userscript.internal_setSettings) { 315 if (this.userscript?.internal_setSettings) {
315 this.userscript.internal_setSettings(this.settings); 316 this.userscript.internal_setSettings(this.settings);
316 } 317 }
317 318
@@ -339,7 +340,7 @@ class RecipeController {
339 'Darkmode enabled?', 340 'Darkmode enabled?',
340 this.settings.service.isDarkModeEnabled, 341 this.settings.service.isDarkModeEnabled,
341 'Dark theme active?', 342 'Dark theme active?',
342 // @ts-ignore 343 // @ts-expect-error Fix this
343 this.settings.app.isDarkThemeActive, 344 this.settings.app.isDarkThemeActive,
344 ); 345 );
345 346
@@ -356,7 +357,7 @@ class RecipeController {
356 debug('Enable dark mode'); 357 debug('Enable dark mode');
357 358
358 // Check if recipe has a custom dark mode handler 359 // Check if recipe has a custom dark mode handler
359 if (this.recipe && this.recipe.darkModeHandler) { 360 if (this.recipe?.darkModeHandler) {
360 debug('Using custom dark mode handler'); 361 debug('Using custom dark mode handler');
361 362
362 // Remove other dark mode styles if they were already loaded 363 // Remove other dark mode styles if they were already loaded
@@ -399,7 +400,7 @@ class RecipeController {
399 debug('Remove dark mode'); 400 debug('Remove dark mode');
400 debug('DarkMode disabled - removing remaining styles'); 401 debug('DarkMode disabled - removing remaining styles');
401 402
402 if (this.recipe && this.recipe.darkModeHandler) { 403 if (this.recipe?.darkModeHandler) {
403 // Remove other dark mode styles if they were already loaded 404 // Remove other dark mode styles if they were already loaded
404 if (this.hasUpdatedBeforeRecipeLoaded) { 405 if (this.hasUpdatedBeforeRecipeLoaded) {
405 this.hasUpdatedBeforeRecipeLoaded = false; 406 this.hasUpdatedBeforeRecipeLoaded = false;