feature/IO-3000-messaging-sockets-migrations2 -
- dumb down archive/unarchive Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -250,7 +250,6 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
|
|
||||||
const { conversationId, type, job_conversations, ...fields } = data;
|
const { conversationId, type, job_conversations, ...fields } = data;
|
||||||
logLocal("handleConversationChanged", data);
|
logLocal("handleConversationChanged", data);
|
||||||
console.log(`--------------${type}-----------------`);
|
|
||||||
|
|
||||||
const updatedAt = new Date().toISOString();
|
const updatedAt = new Date().toISOString();
|
||||||
|
|
||||||
@@ -287,6 +286,23 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
return;
|
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({
|
const cacheId = client.cache.identify({
|
||||||
__typename: "conversations",
|
__typename: "conversations",
|
||||||
id: conversationId
|
id: conversationId
|
||||||
@@ -297,21 +313,6 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
return;
|
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)
|
// Handle other types of updates (e.g., marked read, tags added/removed)
|
||||||
client.cache.modify({
|
client.cache.modify({
|
||||||
id: cacheId,
|
id: cacheId,
|
||||||
|
|||||||
Reference in New Issue
Block a user