feat: implement real-time conversation deletion handling via socket events
This commit is contained in:
@@ -587,6 +587,19 @@ export function useMessaging(options: UseMessagingOptions = {}): UseMessagingRet
|
||||
}
|
||||
);
|
||||
|
||||
// Conversation deleted by the other party — remove from local state
|
||||
const unsubscribeConvDeleted = socketService.onConversationDeleted(
|
||||
(data: Record<string, unknown>) => {
|
||||
const convId = data.conversationId as string | undefined;
|
||||
if (!convId) return;
|
||||
setConversations((prev) => prev.filter((c) => c.id !== convId));
|
||||
if (currentConversationIdRef.current === convId) {
|
||||
currentConversationIdRef.current = null;
|
||||
setMessages([]);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Auth error handling (token refresh + reconnect) is handled globally
|
||||
// by PresenceProvider — no duplicate handler needed here.
|
||||
|
||||
@@ -598,6 +611,7 @@ export function useMessaging(options: UseMessagingOptions = {}): UseMessagingRet
|
||||
unsubscribeStatus();
|
||||
unsubscribeRead();
|
||||
unsubscribeDelivered();
|
||||
unsubscribeConvDeleted();
|
||||
// Clean up typing timeout to prevent memory leak
|
||||
if (typingTimeoutRef.current) {
|
||||
clearTimeout(typingTimeoutRef.current);
|
||||
|
||||
Reference in New Issue
Block a user