From 827cec6d13bd5a6068da0892c7709032e1f6314d Mon Sep 17 00:00:00 2001 From: maTh Date: Fri, 4 Feb 2022 15:54:31 +0100 Subject: 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 --- p/scripts/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'p/scripts') 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(); -- cgit v1.2.3