feature/IO-3478-Mark-Conversation-Unread: Finished

This commit is contained in:
Dave
2025-12-30 14:08:33 -05:00
parent 657720cb10
commit 9dbe246575
7 changed files with 395 additions and 333 deletions

View File

@@ -148,6 +148,26 @@ const cache = new InMemoryCache({
Query: {
fields: {
// Note: This is required because we switch from a read to an unread state with a toggle,
conversations: {
keyArgs: ["where", "order_by"], // keep separate caches for archived/unarchived + sort
merge(existing = [], incoming = [], { args, readField }) {
const offset = args?.offset ?? 0;
const merged = existing ? existing.slice(0) : [];
for (let i = 0; i < incoming.length; i++) {
merged[offset + i] = incoming[i];
}
// Deduplicate by id (important when you also upsert via sockets)
const seen = new Set();
return merged.filter((ref) => {
const id = readField("id", ref);
if (!id || seen.has(id)) return false;
seen.add(id);
return true;
});
}
},
notifications: {
merge(existing = [], incoming = [], { readField }) {
// Create a map to deduplicate by __ref