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/icq/package.json | 2 +- recipes/icq/webview.js | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'recipes/icq') diff --git a/recipes/icq/package.json b/recipes/icq/package.json index 1ce61eb..35de4bb 100644 --- a/recipes/icq/package.json +++ b/recipes/icq/package.json @@ -1,7 +1,7 @@ { "id": "icq", "name": "ICQ", - "version": "1.1.0", + "version": "1.1.1", "license": "MIT", "repository": "https://github.com/meetfranz/recipe-icq", "config": { diff --git a/recipes/icq/webview.js b/recipes/icq/webview.js index 24271d8..653dc69 100644 --- a/recipes/icq/webview.js +++ b/recipes/icq/webview.js @@ -1,15 +1,10 @@ module.exports = Ferdi => { const getMessages = function getMessages() { let directs = 0; - - if (document.getElementsByClassName('nwa-msg-counter icq-recent_state-read').length > 0) { - const elements = document.getElementsByClassName('nwa-msg-counter icq-recent_state-read'); - for (let i = 0; i < elements.length; i++) { - const countLine = parseInt(elements[i].innerText.replace(/[^0-9.]/g, ''), 10); - if (!isNaN(directs) && countLine > 0) { - // directs += count_line; // count every message - directs += 1; // count 1 per channel with messages - } + const elements = document.getElementsByClassName('nwa-msg-counter icq-recent_state-read'); + for (let i = 0; i < elements.length; i++) { + if (Ferdi.safeParseInt(elements[i].innerText.replace(/[^0-9.]/g, '')) > 0) { + directs += 1; // count 1 per channel with messages } } -- cgit v1.2.3-54-g00ecf