From a6bd33fdf8c81d304e7a473b4540b5f3e59e6407 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 7 Aug 2024 23:30:19 -0700 Subject: [PATCH] Fix mute notification links on unread notifications --- web/templates/account/dashboard.html | 37 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/web/templates/account/dashboard.html b/web/templates/account/dashboard.html index 84ffee1..2cec78c 100644 --- a/web/templates/account/dashboard.html +++ b/web/templates/account/dashboard.html @@ -666,19 +666,21 @@ {{if or (eq .Type "also_posted") (eq .Type "also_comment")}} - + Mute this thread {{else if eq .Type "new_photo"}} - + Mute these notifications @@ -854,13 +856,30 @@ document.addEventListener('DOMContentLoaded', () => { window.alert(resp); }).finally(() => { busy = false; - if (href !== undefined) { + if (href !== undefined && href !== "#") { window.location.href = href; } }); }) }); }); + + // "Mute notification" links. + // NOTE: to avoid conflict with the "mark notification as read, then follow href" code + // above, the mute buttons href is made safer and this function will get its follow-thru + // URL from a data attribute. + (document.querySelectorAll(".nonshy-mute-notification-link") || []).forEach(node => { + node.addEventListener("click", (e) => { + e.preventDefault(); + e.stopPropagation(); + + const link = node.dataset.link, + prompt = node.dataset.confirm; + if (!window.confirm(prompt)) return; + + window.location = link; + }); + }); }); {{end}}