From 7566ccd18fae69912c759df0701d1398235a7426 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 19 Sep 2019 11:07:56 +0200 Subject: 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) --- src/webview/lib/RecipeWebview.js | 10 ++++++++-- 1 file 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 { if (this.countCache.direct === direct && this.countCache.indirect === indirect) return; + // Parse number to integer + // This will correct errors that recipes may introduce, e.g. + // by sending a String instead of an integer + const directInt = parseInt(direct); + const indirectInt = parseInt(indirect); + const count = { - direct: direct > 0 ? direct : 0, - indirect: indirect > 0 ? indirect : 0, + direct: directInt > 0 ? directInt : 0, + indirect: indirectInt > 0 ? indirectInt : 0, }; ipcRenderer.sendToHost('messages', count); -- cgit v1.2.3-70-g09d2