Rework notifications list (#24812)

- Replace `<table>` 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 <wxiaoguang@gmail.com>
This commit is contained in:
silverwind 2023-05-25 04:31:26 +02:00 committed by GitHub
parent 309354c70e
commit 27c221aa5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 221 additions and 177 deletions

View file

@ -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(