From dfae2d231e39c81827d08fd8834d736c5b3005b1 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Tue, 31 Aug 2021 16:25:57 +0530 Subject: refactor: Use Ferdi.safeParseInt to ensure that parsing is done consistently in all recipes. --- recipes/wire/webview.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'recipes/wire/webview.js') diff --git a/recipes/wire/webview.js b/recipes/wire/webview.js index efd37f3..b099eee 100644 --- a/recipes/wire/webview.js +++ b/recipes/wire/webview.js @@ -7,10 +7,7 @@ module.exports = (Ferdi) => { const conversationElems = document.querySelectorAll('[data-uie-name="conversation-folder-badge"]'); if (conversationElems) { for (const conversationElem of conversationElems) { - const count = parseInt(conversationElem.innerText); - if (count) { - direct += count; - } + direct += Ferdi.safeParseInt(conversationElem.innerText); } } @@ -18,8 +15,8 @@ module.exports = (Ferdi) => { const pendingElem = document.querySelector('[data-uie-name="item-pending-requests"]'); if (pendingElem) { const matches = pendingElem.innerText.match(/^([1-9][0-9]*)/); - if (matches && matches.length > 0) { - indirect += parseInt(matches[1]); + if (matches && matches.length > 1) { + indirect += Ferdi.safeParseInt(matches[1]); } } -- cgit v1.2.3-54-g00ecf