Merged in release/2024-12-06 (pull request #1991)
feature/IO-3048-Fix-Job-Bug-Messaging - Do not allow more than 1 of the same job to be associated with a conversation
This commit is contained in:
@@ -359,7 +359,7 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
const jobId = client.cache.readFragment({
|
const jobId = client.cache.readFragment({
|
||||||
id: client.cache.identify(jc),
|
id: client.cache.identify(jc),
|
||||||
fragment: gql`
|
fragment: gql`
|
||||||
fragment JobConversationLink on job_conversations {
|
fragment JobConversationLinkAdded on job_conversations {
|
||||||
jobid
|
jobid
|
||||||
conversationid
|
conversationid
|
||||||
}
|
}
|
||||||
@@ -382,20 +382,27 @@ export const registerMessagingHandlers = ({ socket, client }) => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "tag-removed":
|
case "tag-removed":
|
||||||
client.cache.modify({
|
try {
|
||||||
id: client.cache.identify({ __typename: "conversations", id: conversationId }),
|
const conversationCacheId = client.cache.identify({ __typename: "conversations", id: conversationId });
|
||||||
fields: {
|
|
||||||
job_conversations: (existing = [], { readField }) => {
|
|
||||||
return existing.filter((jobRef) => {
|
|
||||||
// Read the `jobid` field safely, even if the structure is normalized
|
|
||||||
const jobId = readField("jobid", jobRef);
|
|
||||||
return jobId !== fields.jobId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
// Evict the specific cache entry for job_conversations
|
||||||
|
client.cache.evict({
|
||||||
|
id: conversationCacheId,
|
||||||
|
fieldName: "job_conversations"
|
||||||
|
});
|
||||||
|
|
||||||
|
// Garbage collect evicted entries
|
||||||
|
client.cache.gc();
|
||||||
|
|
||||||
|
logLocal("handleConversationChanged - tag removed - Refetched conversation list after state change", {
|
||||||
|
conversationId,
|
||||||
|
type
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error refetching queries after conversation state change: (Tag Removed)", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
logLocal("handleConversationChanged - Unhandled type", { type });
|
logLocal("handleConversationChanged - Unhandled type", { type });
|
||||||
client.cache.modify({
|
client.cache.modify({
|
||||||
|
|||||||
Reference in New Issue
Block a user