feature/IO-3497-Ant-Design-v5-to-v6 - Signed off Files (Checkpoint)
This commit is contained in:
@@ -51,21 +51,29 @@ export function ChatPopupComponent({ chatVisible, selectedConversation, toggleCh
|
||||
|
||||
// Query for unread count when chat is not visible and socket is not connected.
|
||||
// (Once socket connects, we stop this query; we keep the last known value in state.)
|
||||
useQuery(UNREAD_CONVERSATION_COUNT, {
|
||||
const { data: unreadData, error: unreadError } = useQuery(UNREAD_CONVERSATION_COUNT, {
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
skip: chatVisible || socket?.connected,
|
||||
pollInterval: socket?.connected ? 0 : 60 * 1000,
|
||||
onCompleted: (result) => {
|
||||
const nextCount = result?.messages_aggregate?.aggregate?.count;
|
||||
if (typeof nextCount === "number") setUnreadAggregateCount(nextCount);
|
||||
},
|
||||
onError: (err) => {
|
||||
// Keep last known count; do not force badge to zero on transient failures
|
||||
console.warn("UNREAD_CONVERSATION_COUNT failed:", err?.message || err);
|
||||
}
|
||||
pollInterval: socket?.connected ? 0 : 60 * 1000
|
||||
});
|
||||
|
||||
// Handle unread count updates in useEffect
|
||||
useEffect(() => {
|
||||
if (unreadData) {
|
||||
const nextCount = unreadData?.messages_aggregate?.aggregate?.count;
|
||||
if (typeof nextCount === "number") setUnreadAggregateCount(nextCount);
|
||||
}
|
||||
}, [unreadData]);
|
||||
|
||||
// Handle unread count errors in useEffect
|
||||
useEffect(() => {
|
||||
if (unreadError) {
|
||||
// Keep last known count; do not force badge to zero on transient failures
|
||||
console.warn("UNREAD_CONVERSATION_COUNT failed:", unreadError?.message || unreadError);
|
||||
}
|
||||
}, [unreadError]);
|
||||
|
||||
// Socket connection status -> polling strategy for CONVERSATION_LIST_QUERY
|
||||
useEffect(() => {
|
||||
const handleSocketStatus = () => {
|
||||
|
||||
Reference in New Issue
Block a user