diff options
author | 2021-08-31 16:25:57 +0530 | |
---|---|---|
committer | 2021-08-31 16:25:57 +0530 | |
commit | dfae2d231e39c81827d08fd8834d736c5b3005b1 (patch) | |
tree | 5037b401e7de837fdd6046a3c61ac76aed240e6e /recipes/element/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/element/webview.js')
-rw-r--r-- | recipes/element/webview.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/recipes/element/webview.js b/recipes/element/webview.js index 18bb7ad..c1fdea3 100644 --- a/recipes/element/webview.js +++ b/recipes/element/webview.js | |||
@@ -3,19 +3,19 @@ module.exports = Ferdi => { | |||
3 | const badges = document.querySelectorAll('.mx_RoomSublist:not(.mx_RoomSublist_hidden) .mx_RoomSublist_badgeContainer'); | 3 | const badges = document.querySelectorAll('.mx_RoomSublist:not(.mx_RoomSublist_hidden) .mx_RoomSublist_badgeContainer'); |
4 | 4 | ||
5 | // Number of messages from People | 5 | // Number of messages from People |
6 | let direct_count = 0; | 6 | let directCount = 0; |
7 | if (badges.length > 0 && badges[0].children.length > 0) { | 7 | if (badges.length > 0) { |
8 | direct_count = parseInt(badges[0].textContent); | 8 | directCount = Ferdi.safeParseInt(badges[0].textContent); |
9 | } | 9 | } |
10 | 10 | ||
11 | // Number of messages from Rooms | 11 | // Number of messages from Rooms |
12 | let indirect_count = 0; | 12 | let indirectCount = 0; |
13 | if (badges.length > 1 && badges[1].children.length > 0) { | 13 | if (badges.length > 1) { |
14 | indirect_count = parseInt(badges[1].textContent); | 14 | indirectCount = Ferdi.safeParseInt(badges[1].textContent); |
15 | } | 15 | } |
16 | 16 | ||
17 | // set Ferdi badge | 17 | // set Ferdi badge |
18 | Ferdi.setBadge(direct_count, indirect_count); | 18 | Ferdi.setBadge(directCount, indirectCount); |
19 | } | 19 | } |
20 | 20 | ||
21 | Ferdi.loop(getMessages); | 21 | Ferdi.loop(getMessages); |