feat(notifications): add delete functionality for individual and all notifications
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m26s
All checks were successful
Build & Push Docker Image / build (push) Successful in 6m26s
feat(guest-join): support access code in guest join URL
This commit is contained in:
@@ -71,8 +71,29 @@ export function NotificationProvider({ children }) {
|
||||
} catch { /* silent */ }
|
||||
};
|
||||
|
||||
const deleteNotification = async (id) => {
|
||||
try {
|
||||
await api.delete(`/notifications/${id}`);
|
||||
setNotifications(prev => {
|
||||
const removed = prev.find(n => n.id === id);
|
||||
if (removed && !removed.read) setUnreadCount(c => Math.max(0, c - 1));
|
||||
return prev.filter(n => n.id !== id);
|
||||
});
|
||||
seenIds.current.delete(id);
|
||||
} catch { /* silent */ }
|
||||
};
|
||||
|
||||
const clearAll = async () => {
|
||||
try {
|
||||
await api.delete('/notifications/all');
|
||||
setNotifications([]);
|
||||
setUnreadCount(0);
|
||||
seenIds.current = new Set();
|
||||
} catch { /* silent */ }
|
||||
};
|
||||
|
||||
return (
|
||||
<NotificationContext.Provider value={{ notifications, unreadCount, markRead, markAllRead, refresh: fetch }}>
|
||||
<NotificationContext.Provider value={{ notifications, unreadCount, markRead, markAllRead, deleteNotification, clearAll, refresh: fetch }}>
|
||||
{children}
|
||||
</NotificationContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user