diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/contextMenu.js | 2 | ||||
-rw-r--r-- | src/webview/darkmode.js | 2 | ||||
-rw-r--r-- | src/webview/darkmode/ignore.js | 3 | ||||
-rw-r--r-- | src/webview/lib/RecipeWebview.js | 10 | ||||
-rw-r--r-- | src/webview/notifications.js | 2 | ||||
-rw-r--r-- | src/webview/recipe.js | 32 | ||||
-rw-r--r-- | src/webview/spellchecker.js | 2 |
7 files changed, 42 insertions, 11 deletions
diff --git a/src/webview/contextMenu.js b/src/webview/contextMenu.js index d3b976554..acd62d675 100644 --- a/src/webview/contextMenu.js +++ b/src/webview/contextMenu.js | |||
@@ -8,7 +8,7 @@ import { | |||
8 | import { isDevMode, isMac } from '../environment'; | 8 | import { isDevMode, isMac } from '../environment'; |
9 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 9 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
10 | 10 | ||
11 | const debug = require('debug')('Franz:contextMenu'); | 11 | const debug = require('debug')('Ferdi:contextMenu'); |
12 | 12 | ||
13 | const { Menu } = remote; | 13 | const { Menu } = remote; |
14 | 14 | ||
diff --git a/src/webview/darkmode.js b/src/webview/darkmode.js index 73c7007c6..ab629435c 100644 --- a/src/webview/darkmode.js +++ b/src/webview/darkmode.js | |||
@@ -3,7 +3,7 @@ | |||
3 | import path from 'path'; | 3 | import path from 'path'; |
4 | import fs from 'fs-extra'; | 4 | import fs from 'fs-extra'; |
5 | 5 | ||
6 | const debug = require('debug')('Franz:DarkMode'); | 6 | const debug = require('debug')('Ferdi:DarkMode'); |
7 | 7 | ||
8 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; | 8 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; |
9 | 9 | ||
diff --git a/src/webview/darkmode/ignore.js b/src/webview/darkmode/ignore.js new file mode 100644 index 000000000..110df364f --- /dev/null +++ b/src/webview/darkmode/ignore.js | |||
@@ -0,0 +1,3 @@ | |||
1 | export default [ | ||
2 | 'discordapp.com', | ||
3 | ]; | ||
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index be29142af..877e45e35 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js | |||
@@ -39,9 +39,15 @@ class RecipeWebview { | |||
39 | if (this.countCache.direct === direct | 39 | if (this.countCache.direct === direct |
40 | && this.countCache.indirect === indirect) return; | 40 | && this.countCache.indirect === indirect) return; |
41 | 41 | ||
42 | // Parse number to integer | ||
43 | // This will correct errors that recipes may introduce, e.g. | ||
44 | // by sending a String instead of an integer | ||
45 | const directInt = parseInt(direct, 10); | ||
46 | const indirectInt = parseInt(indirect, 10); | ||
47 | |||
42 | const count = { | 48 | const count = { |
43 | direct: direct > 0 ? direct : 0, | 49 | direct: directInt > 0 ? directInt : 0, |
44 | indirect: indirect > 0 ? indirect : 0, | 50 | indirect: indirectInt > 0 ? indirectInt : 0, |
45 | }; | 51 | }; |
46 | 52 | ||
47 | ipcRenderer.sendToHost('messages', count); | 53 | ipcRenderer.sendToHost('messages', count); |
diff --git a/src/webview/notifications.js b/src/webview/notifications.js index f8fe53e1b..021f05cc3 100644 --- a/src/webview/notifications.js +++ b/src/webview/notifications.js | |||
@@ -1,7 +1,7 @@ | |||
1 | import { ipcRenderer } from 'electron'; | 1 | import { ipcRenderer } from 'electron'; |
2 | import uuidV1 from 'uuid/v1'; | 2 | import uuidV1 from 'uuid/v1'; |
3 | 3 | ||
4 | const debug = require('debug')('Franz:Notifications'); | 4 | const debug = require('debug')('Ferdi:Notifications'); |
5 | 5 | ||
6 | class Notification { | 6 | class Notification { |
7 | static permission = 'granted'; | 7 | static permission = 'granted'; |
diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e3e13b726..3f2338b68 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js | |||
@@ -1,8 +1,15 @@ | |||
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'; | ||
11 | |||
12 | import ignoreList from './darkmode/ignore'; | ||
6 | 13 | ||
7 | import RecipeWebview from './lib/RecipeWebview'; | 14 | import RecipeWebview from './lib/RecipeWebview'; |
8 | 15 | ||
@@ -14,7 +21,7 @@ import './notifications'; | |||
14 | import { DEFAULT_APP_SETTINGS } from '../config'; | 21 | import { DEFAULT_APP_SETTINGS } from '../config'; |
15 | import { isDevMode } from '../environment'; | 22 | import { isDevMode } from '../environment'; |
16 | 23 | ||
17 | const debug = require('debug')('Franz:Plugin'); | 24 | const debug = require('debug')('Ferdi:Plugin'); |
18 | 25 | ||
19 | class RecipeController { | 26 | class RecipeController { |
20 | @observable settings = { | 27 | @observable settings = { |
@@ -110,12 +117,27 @@ class RecipeController { | |||
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | if (this.settings.service.isDarkModeEnabled) { | 120 | if (this.settings.service.isDarkModeEnabled || this.settings.app.darkMode) { |
114 | debug('Enable dark mode'); | 121 | debug('Enable dark mode'); |
115 | injectDarkModeStyle(this.settings.service.recipe.path); | 122 | |
116 | } else if (isDarkModeStyleInjected()) { | 123 | // Check if recipe has a darkmode.css |
124 | const darkModeStyle = path.join(this.settings.service.recipe.path, 'darkmode.css'); | ||
125 | const darkModeExists = fs.pathExistsSync(darkModeStyle); | ||
126 | |||
127 | if (darkModeExists) { | ||
128 | injectDarkModeStyle(this.settings.service.recipe.path); | ||
129 | } else if (!ignoreList.includes(window.location.host)) { | ||
130 | // Use darkreader instead | ||
131 | enableDarkMode(); | ||
132 | } | ||
133 | } else { | ||
117 | debug('Remove dark mode'); | 134 | debug('Remove dark mode'); |
118 | removeDarkModeStyle(); | 135 | |
136 | if (isDarkModeStyleInjected()) { | ||
137 | removeDarkModeStyle(); | ||
138 | } else { | ||
139 | disableDarkMode(); | ||
140 | } | ||
119 | } | 141 | } |
120 | } | 142 | } |
121 | 143 | ||
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js index 06cbd283a..27380676d 100644 --- a/src/webview/spellchecker.js +++ b/src/webview/spellchecker.js | |||
@@ -6,7 +6,7 @@ import { readFileSync } from 'fs'; | |||
6 | import { DICTIONARY_PATH } from '../config'; | 6 | import { DICTIONARY_PATH } from '../config'; |
7 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | 7 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; |
8 | 8 | ||
9 | const debug = require('debug')('Franz:spellchecker'); | 9 | const debug = require('debug')('Ferdi:spellchecker'); |
10 | 10 | ||
11 | let provider; | 11 | let provider; |
12 | let currentDict; | 12 | let currentDict; |