18 lines
591 B
JavaScript
18 lines
591 B
JavaScript
const notifications = [...document.querySelectorAll('.notification')]
|
|
for (const notification of notifications) {
|
|
notification.addEventListener('click', () => {
|
|
fetch(`/notifications/${notification.dataset.notificationId}`, {
|
|
method: 'DELETE'
|
|
})
|
|
const hiddenNotification = document.querySelector('.notification.hidden')
|
|
if ('startViewTransition' in document) {
|
|
document.startViewTransition(() => {
|
|
notification.remove()
|
|
hiddenNotification?.classList.remove('hidden')
|
|
})
|
|
} else {
|
|
notification.remove()
|
|
hiddenNotification?.classList.remove('hidden')
|
|
}
|
|
})
|
|
} |