feature/IO-3000-messaging-sockets-migrations2 -

- dumb down archive/unarchive

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-11-21 19:21:51 -08:00
parent 525f795ce0
commit 12ed8d3830

View File

@@ -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,