diff options
author | vantezzen <properly@protonmail.com> | 2019-09-19 11:07:56 +0200 |
---|---|---|
committer | vantezzen <properly@protonmail.com> | 2019-09-19 11:07:56 +0200 |
commit | 7566ccd18fae69912c759df0701d1398235a7426 (patch) | |
tree | a658c5fef49132b7e1fe5b1d80256d60cb0013af /src/webview/lib | |
parent | Review all-contributors settings and re-render (diff) | |
download | ferdium-app-7566ccd18fae69912c759df0701d1398235a7426.tar.gz ferdium-app-7566ccd18fae69912c759df0701d1398235a7426.tar.zst ferdium-app-7566ccd18fae69912c759df0701d1398235a7426.zip |
Parse unread messages count as integer before sending to host
This will correct errors that recipes may introduce, e.g. by sending a String instead of an integer (as seen on old versions of the ProtonMail recipe)
Diffstat (limited to 'src/webview/lib')
-rw-r--r-- | src/webview/lib/RecipeWebview.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index be29142af..cae6c7dc4 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); | ||
46 | const indirectInt = parseInt(indirect); | ||
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); |