From 27c221aa5db116e2cc90afbfa9b92f2a220af853 Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 25 May 2023 04:31:26 +0200 Subject: Rework notifications list (#24812) - Replace `` with flexbox - Add issue modification time and issue number - Remove big title - Replace tabs with menu items - Add clicked item deletion on back button cache restoration --------- Co-authored-by: wxiaoguang --- web_src/js/features/notification.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'web_src/js') diff --git a/web_src/js/features/notification.js b/web_src/js/features/notification.js index 6c056c6d14..0c24d36e56 100644 --- a/web_src/js/features/notification.js +++ b/web_src/js/features/notification.js @@ -4,6 +4,30 @@ const {appSubUrl, csrfToken, notificationSettings, assetVersionEncoded} = window let notificationSequenceNumber = 0; export function initNotificationsTable() { + const table = document.getElementById('notification_table'); + if (!table) return; + + // when page restores from bfcache, delete previously clicked items + window.addEventListener('pageshow', (e) => { + if (e.persisted) { // page was restored from bfcache + const table = document.getElementById('notification_table'); + const unreadCountEl = document.querySelector('.notifications-unread-count'); + let unreadCount = parseInt(unreadCountEl.textContent); + for (const item of table.querySelectorAll('.notifications-item[data-remove="true"]')) { + item.remove(); + unreadCount -= 1; + } + unreadCountEl.textContent = unreadCount; + } + }); + + // mark clicked unread links for deletion on bfcache restore + for (const link of table.querySelectorAll('.notifications-item[data-status="1"] .notifications-link')) { + link.addEventListener('click', (e) => { + e.target.closest('.notifications-item').setAttribute('data-remove', 'true'); + }); + } + $('#notification_table .button').on('click', function () { (async () => { const data = await updateNotification( -- cgit v1.2.3