diff --git a/public/s/js/f0ckm.js b/public/s/js/f0ckm.js index 399a7f0..2ac2d0b 100644 --- a/public/s/js/f0ckm.js +++ b/public/s/js/f0ckm.js @@ -525,21 +525,26 @@ window.cancelAnimFrame = (function () { if (!itemMode || thumb.classList.contains('revealed')) return; if (_notifBlurShouldBlur(itemMode, mode)) { - if (!img.dataset.origSrc) { - // Extract numeric item ID from any thumbnail path variant: - // /t/{id}.webp, /mod/pending/t/{id}.webp, /mod/deleted/t/{id}.webp - const idMatch = img.src.match(/\/t\/(\d+)\.webp/); + if (!thumb.classList.contains('notif-thumb-blurred')) { + const htmlOrigSrc = img.getAttribute('data-orig-src'); + const idMatch = img.src.match(/\/t\/(\d+)(?:_blur)?\.webp/); if (idMatch) { - // Always use the canonical /t/{id}.webp as the sharp src (hover target) - img.dataset.origSrc = `/t/${idMatch[1]}.webp`; - img.src = `/t/${idMatch[1]}_blur.webp`; + // Ensure JS dataset has origSrc (server may have set it via HTML attribute) + if (!img.dataset.origSrc) { + img.dataset.origSrc = htmlOrigSrc || `/t/${idMatch[1]}.webp`; + } + // Only swap src if not already the blur version + if (!img.src.includes('_blur.webp')) { + img.src = `/t/${idMatch[1]}_blur.webp`; + } thumb.classList.add('notif-thumb-blurred'); } } } else { // Restore original thumbnail - if (img.dataset.origSrc) { - img.src = img.dataset.origSrc; + const origSrc = img.dataset.origSrc || img.getAttribute('data-orig-src'); + if (origSrc) { + img.src = origSrc; delete img.dataset.origSrc; thumb.classList.remove('notif-thumb-blurred'); } @@ -548,6 +553,7 @@ window.cancelAnimFrame = (function () { }; + const _updateNotifFilterClass = (mode) => { const modeNames = { 0: 'sfw', 1: 'nsfw', 2: 'untagged', 3: 'all', 4: 'nsfl' }; htmlEl.setAttribute('data-notif-filter', modeNames[mode] || 'all'); diff --git a/src/inc/routes/notifications.mjs b/src/inc/routes/notifications.mjs index ab203de..5c33400 100644 --- a/src/inc/routes/notifications.mjs +++ b/src/inc/routes/notifications.mjs @@ -669,6 +669,7 @@ export default (router, tpl) => { data.link = { main: '/notifications', path: '/' }; data.activeTab = tab; data.domain = cfg.main.url.domain; // For header + data.active_mode = req.session?.mode ?? 0; return res.html(tpl.render('notifications', data, req)); }); @@ -681,7 +682,7 @@ export default (router, tpl) => { const tab = req.url.qs.tab || null; const data = await getNotificationHistory(req.session.id, page, 50, tab); - const html = tpl.render('snippets/notifications-list', data, req); + const html = tpl.render('snippets/notifications-list', { ...data, active_mode: req.session?.mode ?? 0 }, req); return res.json({ success: true, diff --git a/views/snippets/notifications-list.html b/views/snippets/notifications-list.html index 3fa3012..c142a86 100644 --- a/views/snippets/notifications-list.html +++ b/views/snippets/notifications-list.html @@ -2,7 +2,7 @@ @if(n.type === 'approve')
- thumb + thumb
{{ t('notifications.system') }}
@@ -13,7 +13,7 @@ @elseif(n.type === 'admin_pending')
- thumb + thumb
{{ t('notifications.admin') }}
@@ -24,7 +24,7 @@ @elseif(n.type === 'report')
- thumb + thumb