diff options
author | 2021-08-31 16:25:57 +0530 | |
---|---|---|
committer | 2021-08-31 16:25:57 +0530 | |
commit | dfae2d231e39c81827d08fd8834d736c5b3005b1 (patch) | |
tree | 5037b401e7de837fdd6046a3c61ac76aed240e6e /recipes/chatwork/webview.js | |
parent | New recipe: odoo (diff) | |
download | ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.tar.gz ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.tar.zst ferdium-recipes-dfae2d231e39c81827d08fd8834d736c5b3005b1.zip |
refactor: Use Ferdi.safeParseInt to ensure that parsing is done consistently in all recipes.
Diffstat (limited to 'recipes/chatwork/webview.js')
-rw-r--r-- | recipes/chatwork/webview.js | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/recipes/chatwork/webview.js b/recipes/chatwork/webview.js index e131093..cc40834 100644 --- a/recipes/chatwork/webview.js +++ b/recipes/chatwork/webview.js | |||
@@ -1,7 +1,5 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = (Ferdi) => { |
2 | function getMessages() { | 2 | function getMessages() { |
3 | let groupCount = 0; | ||
4 | let individualCount = 0; | ||
5 | let directCount = 0; | 3 | let directCount = 0; |
6 | let indirectCount = 0; | 4 | let indirectCount = 0; |
7 | const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq'); | 5 | const roomInfoContainer = document.querySelectorAll('li.sc-dnqmqq'); |
@@ -11,20 +9,17 @@ module.exports = (Ferdi) => { | |||
11 | const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG'); | 9 | const unreadBadgeHasMention = room.querySelector('li._unreadBadge.sc-cSHVUG'); |
12 | 10 | ||
13 | if (unreadBadge && unreadBadge.innerText) { | 11 | if (unreadBadge && unreadBadge.innerText) { |
14 | count = parseInt(unreadBadge.innerText); | 12 | count = Ferdi.safeParseInt(unreadBadge.innerText); |
15 | } | 13 | } |
16 | 14 | ||
17 | if (count > 0) { | 15 | if (count > 0) { |
18 | if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) { | 16 | if (room.querySelector('img.sc-gqjmRU').getAttribute('src').indexOf('avatar') < 0) { |
19 | groupCount += count; | ||
20 | |||
21 | if (unreadBadgeHasMention) { | 17 | if (unreadBadgeHasMention) { |
22 | directCount++; | 18 | directCount++; |
23 | } else { | 19 | } else { |
24 | indirectCount++; | 20 | indirectCount++; |
25 | } | 21 | } |
26 | } else { | 22 | } else { |
27 | individualCount += count; | ||
28 | directCount++; | 23 | directCount++; |
29 | } | 24 | } |
30 | } | 25 | } |