From 12ed8d3830534aed4cdb946d5b9e0997d689ae8b Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 21 Nov 2024 19:21:51 -0800 Subject: [PATCH] feature/IO-3000-messaging-sockets-migrations2 - - dumb down archive/unarchive Signed-off-by: Dave Richer --- .../registerMessagingSocketHandlers.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) 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,