aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar maTh <math-home@web.de> 2022-02-04 15:54:31 +0100
committerGravatar GitHub <noreply@github.com> 2022-02-04 15:54:31 +0100
commit827cec6d13bd5a6068da0892c7709032e1f6314d (patch)
tree941c5a0163c6df7b1b0fa31db7704c96d174fbd5 /p/scripts
parentb127777887969617ed8358912876af962edde139 (diff)
Improved: Browser notification: unread message (#4193)
* notification * i18n (english string) * i18n: en-us + de * Update gen.php * i18n: PL + RU * Update app/i18n/fr/gen.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index e4642dbcb..cdf3a1324 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1435,14 +1435,14 @@ function notifs_html5_ask_permission() {
});
}
-function notifs_html5_show(nb) {
+function notifs_html5_show(nb, nb_new) {
if (notifs_html5_permission !== 'granted') {
return;
}
const notification = new window.Notification(context.i18n.notif_title_articles, {
icon: '../themes/icons/favicon-256-padding.png',
- body: context.i18n.notif_body_articles.replace('%d', nb),
+ body: context.i18n.notif_body_new_articles.replace('%d', nb_new) + ' ' + context.i18n.notif_body_unread_articles.replace('%d', nb),
tag: 'freshRssNewArticles',
});
@@ -1482,6 +1482,8 @@ function refreshUnreads() {
const isAll = document.querySelector('.category.all.active');
let new_articles = false;
let nbUnreadFeeds = 0;
+ const title = document.querySelector('.category.all .title');
+ const nb_unreads_before = title ? str2int(title.getAttribute('data-unread')) : 0;
Object.keys(json.feeds).forEach(function (feed_id) {
const nbUnreads = json.feeds[feed_id];
@@ -1522,12 +1524,12 @@ function refreshUnreads() {
tags.querySelector('.title').setAttribute('data-unread', numberFormat(nbUnreadTags));
}
- const title = document.querySelector('.category.all .title');
const nb_unreads = title ? str2int(title.getAttribute('data-unread')) : 0;
if (nb_unreads > 0 && new_articles) {
faviconNbUnread(nb_unreads);
- notifs_html5_show(nb_unreads);
+ const nb_new = nb_unreads - nb_unreads_before;
+ notifs_html5_show(nb_unreads, nb_new);
}
};
req.send();