diff options
author | Vijay A <avijayr@protonmail.com> | 2021-08-31 16:25:57 +0530 |
---|---|---|
committer | Vijay A <avijayr@protonmail.com> | 2021-08-31 16:25:57 +0530 |
commit | dfae2d231e39c81827d08fd8834d736c5b3005b1 (patch) | |
tree | 5037b401e7de837fdd6046a3c61ac76aed240e6e /recipes/slite/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/slite/webview.js')
-rw-r--r-- | recipes/slite/webview.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/recipes/slite/webview.js b/recipes/slite/webview.js index d892c3c..a044399 100644 --- a/recipes/slite/webview.js +++ b/recipes/slite/webview.js | |||
@@ -1,15 +1,7 @@ | |||
1 | const getInnerInt = selector => { | ||
2 | const element = document.querySelector(selector); | ||
3 | return element && parseInt(element.innerText); | ||
4 | }; | ||
5 | |||
6 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
7 | const getMessages = function getMessages() { | 2 | const getMessages = function getMessages() { |
8 | const direct = ( | 3 | const element = document.querySelector("#app button[data-test-id='notificationsCount']"); |
9 | getInnerInt("#app button[data-test-id='notificationsCount']") || 0 | 4 | Ferdi.setBadge(element ? Ferdi.safeParseInt(element.innerText) : 0); |
10 | ); | ||
11 | |||
12 | Ferdi.setBadge(direct); | ||
13 | }; | 5 | }; |
14 | 6 | ||
15 | Ferdi.loop(getMessages); | 7 | Ferdi.loop(getMessages); |