feat(moderation): add real-time status updates via WebSocket

Broadcast moderation status changes to the author via WebSocket
Update UI in real-time for Life Posts, Comments, and Discussions
Hide retry moderation button while status is reviewing
This commit is contained in:
2026-05-04 10:54:21 +08:00
parent a25f1661b5
commit 3d6188748d
7 changed files with 335 additions and 16 deletions

View File

@@ -17,6 +17,7 @@ import {
import {
api,
getAuthToken,
moderationUpdateEvent,
notificationWebSocketUrl,
type AuthUser,
type LifeReactionType,
@@ -140,9 +141,13 @@ async function connectNotifications() {
return;
}
unreadCount.value = message.unreadCount;
if ('unreadCount' in message) {
unreadCount.value = message.unreadCount;
}
if (message.type === 'notifications.created') {
upsertNotification(message.notification);
} else if (message.type === 'moderation.updated') {
window.dispatchEvent(new CustomEvent(moderationUpdateEvent, { detail: message }));
}
} catch {
// Invalid socket payloads are ignored.