feature/IO-3000-messaging-sockets-migration2 -
- Various work Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -149,39 +149,6 @@ const cache = new InMemoryCache({
|
||||
fields: {
|
||||
conversations: offsetLimitPagination()
|
||||
}
|
||||
},
|
||||
conversations: {
|
||||
fields: {
|
||||
job_conversations: {
|
||||
keyArgs: false, // Indicates that all job_conversations share the same key
|
||||
merge(existing = [], incoming) {
|
||||
// Merge existing and incoming job_conversations
|
||||
const merged = [
|
||||
...existing,
|
||||
...incoming.filter(
|
||||
(incomingItem) => !existing.some((existingItem) => existingItem.__ref === incomingItem.__ref)
|
||||
)
|
||||
];
|
||||
return merged;
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
keyArgs: false, // Ignore arguments when determining uniqueness (like `order_by`).
|
||||
merge(existing = [], incoming = [], { readField }) {
|
||||
const existingIds = new Set(existing.map((message) => readField("id", message)));
|
||||
|
||||
// Merge incoming messages, avoiding duplicates
|
||||
const merged = [...existing];
|
||||
incoming.forEach((message) => {
|
||||
if (!existingIds.has(readField("id", message))) {
|
||||
merged.push(message);
|
||||
}
|
||||
});
|
||||
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user