aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-10-22 19:02:39 +0200
committerGravatar GitHub <noreply@github.com> 2023-10-22 19:02:39 +0200
commit430d467b5a98c6691ed87180f0f15ddb111c213b (patch)
tree2394eff2c8aef69f0ade28c67b4fc545d37d9352 /p/scripts
parent3116fbdbc0095565995ee509e0037cced3120d0a (diff)
Try Catch for window.Notification (#5690)
fix https://github.com/FreshRSS/FreshRSS/issues/5687 Exceptions might be thrown in some cases https://developer.mozilla.org/docs/Web/API/Notification/Notification
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/main.js44
1 files changed, 25 insertions, 19 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js
index e87636863..93aac281e 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -1602,9 +1602,12 @@ function notifs_html5_is_supported() {
}
function notifs_html5_ask_permission() {
- window.Notification.requestPermission(function () {
- notifs_html5_permission = window.Notification.permission;
- });
+ try {
+ window.Notification.requestPermission(function () {
+ notifs_html5_permission = window.Notification.permission;
+ });
+ } catch (e) {
+ }
}
function notifs_html5_show(nb, nb_new) {
@@ -1612,24 +1615,27 @@ function notifs_html5_show(nb, nb_new) {
return;
}
- const notification = new window.Notification(context.i18n.notif_title_articles, {
- icon: '../themes/icons/favicon-256-padding.png',
- body: context.i18n.notif_body_new_articles.replace('%%d', nb_new) + ' ' + context.i18n.notif_body_unread_articles.replace('%%d', nb),
- tag: 'freshRssNewArticles',
- });
-
- notification.onclick = function () {
- delayedFunction(function () {
- location.reload();
- window.focus();
- notification.close();
+ try {
+ const notification = new window.Notification(context.i18n.notif_title_articles, {
+ icon: '../themes/icons/favicon-256-padding.png',
+ body: context.i18n.notif_body_new_articles.replace('%%d', nb_new) + ' ' + context.i18n.notif_body_unread_articles.replace('%%d', nb),
+ tag: 'freshRssNewArticles',
});
- };
- if (context.html5_notif_timeout !== 0) {
- setTimeout(function () {
- notification.close();
- }, context.html5_notif_timeout * 1000);
+ notification.onclick = function () {
+ delayedFunction(function () {
+ location.reload();
+ window.focus();
+ notification.close();
+ });
+ };
+
+ if (context.html5_notif_timeout !== 0) {
+ setTimeout(function () {
+ notification.close();
+ }, context.html5_notif_timeout * 1000);
+ }
+ } catch (e) {
}
}