diff options
author | 2023-07-26 06:29:03 -0600 | |
---|---|---|
committer | 2023-07-26 17:59:03 +0530 | |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/tt-rss/webview.js | |
parent | Add Excalidraw recipe (#393) (diff) | |
download | ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip |
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app
- add .eslintignore
- opt in to eslint `reportUnusedDisableDirectives` config option
- remove `trailingComma: all` from `prettier` config which is default in `prettier` v3
- autofix or disable a lot of lint issues throughout codebase
- add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions
- upgrade all `eslint` and `prettier` related dependencies to latest
- update lint:fix npm script
- reformat touched files with prettier
- bumped up minor version for all recipes that have changes
- introduced injection of 'service.css' where it was missing in many recipes
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/tt-rss/webview.js')
-rw-r--r-- | recipes/tt-rss/webview.js | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/recipes/tt-rss/webview.js b/recipes/tt-rss/webview.js index 7d90615..e0581ce 100644 --- a/recipes/tt-rss/webview.js +++ b/recipes/tt-rss/webview.js | |||
@@ -1,24 +1,22 @@ | |||
1 | "use strict"; | 1 | function _interopRequireDefault(obj) { |
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
2 | 6 | ||
3 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
4 | const _notificationCategory = new URL(window.location.href).searchParams.get("ferdiumNotificationCategory"); | 8 | const _notificationCategory = new URL(window.location.href).searchParams.get( |
5 | 9 | 'ferdiumNotificationCategory', | |
6 | const getMessages = function getMessages() { | 10 | ); |
7 | if (_notificationCategory) { | ||
8 | countMessagesUnderCategory(_notificationCategory); | ||
9 | } else { | ||
10 | countMessages(); | ||
11 | } | ||
12 | }; | ||
13 | 11 | ||
14 | const countMessagesUnderCategory = (notificationCategory) => { | 12 | const countMessagesUnderCategory = notificationCategory => { |
15 | var elements = document.querySelectorAll(".dijitTreeIsRoot") | 13 | const elements = document.querySelectorAll('.dijitTreeIsRoot'); |
16 | var directMessages = 0; | 14 | let directMessages = 0; |
17 | var indirectMessages = 0; | 15 | let indirectMessages = 0; |
18 | for (var element of elements) { | 16 | for (const element of elements) { |
19 | var label = element.querySelectorAll(".dijitTreeLabel")[0]; | 17 | const label = element.querySelectorAll('.dijitTreeLabel')[0]; |
20 | var unreadNode = element.querySelectorAll(".unread")[0]; | 18 | const unreadNode = element.querySelectorAll('.unread')[0]; |
21 | var unreadAmount = Ferdium.safeParseInt(unreadNode.textContent); | 19 | const unreadAmount = Ferdium.safeParseInt(unreadNode.textContent); |
22 | if (label.textContent === notificationCategory) { | 20 | if (label.textContent === notificationCategory) { |
23 | directMessages += unreadAmount; | 21 | directMessages += unreadAmount; |
24 | } else { | 22 | } else { |
@@ -29,18 +27,28 @@ module.exports = Ferdium => { | |||
29 | }; | 27 | }; |
30 | 28 | ||
31 | const _countMessagesFromTitle = () => { | 29 | const _countMessagesFromTitle = () => { |
32 | var match = document.title.match(/^\((\d+)\) Tiny Tiny RSS$/); | 30 | const match = document.title.match(/^\((\d+)\) Tiny Tiny RSS$/); |
33 | var count = match != null && match.length > 0 ? match[1] : 0; | 31 | const count = match !== null && match.length > 0 ? match[1] : 0; |
34 | return Ferdium.safeParseInt(count); | 32 | return Ferdium.safeParseInt(count); |
35 | } | 33 | }; |
36 | 34 | ||
37 | const countMessages = () => { | 35 | const countMessages = () => { |
38 | Ferdium.setBadge(_countMessagesFromTitle()); | 36 | Ferdium.setBadge(_countMessagesFromTitle()); |
39 | }; | 37 | }; |
40 | 38 | ||
39 | const getMessages = function getMessages() { | ||
40 | if (_notificationCategory) { | ||
41 | countMessagesUnderCategory(_notificationCategory); | ||
42 | } else { | ||
43 | countMessages(); | ||
44 | } | ||
45 | }; | ||
46 | |||
41 | const loopFunc = () => { | 47 | const loopFunc = () => { |
42 | getMessages(); | 48 | getMessages(); |
43 | }; | 49 | }; |
44 | 50 | ||
45 | Ferdium.loop(loopFunc); | 51 | Ferdium.loop(loopFunc); |
52 | |||
53 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
46 | }; | 54 | }; |