diff --git a/client/src/components/chat-affix/registerMessagingSocketHandlers.js b/client/src/components/chat-affix/registerMessagingSocketHandlers.js index 8034353c8..a20781dec 100644 --- a/client/src/components/chat-affix/registerMessagingSocketHandlers.js +++ b/client/src/components/chat-affix/registerMessagingSocketHandlers.js @@ -250,7 +250,6 @@ export const registerMessagingHandlers = ({ socket, client }) => { const { conversationId, type, job_conversations, ...fields } = data; logLocal("handleConversationChanged", data); - console.log(`--------------${type}-----------------`); const updatedAt = new Date().toISOString(); @@ -287,6 +286,23 @@ export const registerMessagingHandlers = ({ socket, client }) => { return; } + if (type === "conversation-unarchived" || type === "conversation-archived") { + try { + // Refetch the conversation list and details queries + await client.refetchQueries({ + include: [CONVERSATION_LIST_QUERY, GET_CONVERSATION_DETAILS], + variables: [ + { query: CONVERSATION_LIST_QUERY, variables: { offset: 0 } }, + { query: GET_CONVERSATION_DETAILS, variables: { conversationId } } + ] + }); + } catch (error) { + console.error("Error refetching queries after conversation state change:", error); + } + + return; + } + const cacheId = client.cache.identify({ __typename: "conversations", id: conversationId @@ -297,21 +313,6 @@ export const registerMessagingHandlers = ({ socket, client }) => { return; } - if (type === "conversation-unarchived" || type === "conversation-archived") { - try { - // Refetch the conversation list query to update the UI - const queryVariables = { offset: 0 }; - await client.refetchQueries({ - include: [CONVERSATION_LIST_QUERY], - variables: queryVariables - }); - } catch (error) { - console.error("Error refetching conversation list after unarchiving:", error); - } - - return; - } - // Handle other types of updates (e.g., marked read, tags added/removed) client.cache.modify({ id: cacheId,