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

- Checkpoint, archiving works, cannot unarchive yet

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-11-21 13:23:28 -08:00
parent e734da7adc
commit 1cdd905037
4 changed files with 35 additions and 1 deletions

View File

@@ -152,6 +152,38 @@ export const registerMessagingHandlers = ({ socket, client }) => {
return;
}
if (type === "conversation-archived") {
// Remove all messages associated with this conversation
const messageRefs = client.cache.readFragment({
id: cacheId,
fragment: gql`
fragment ConversationMessages on conversations {
messages {
id
}
}
`
});
if (messageRefs?.messages) {
messageRefs.messages.forEach((message) => {
const messageCacheId = client.cache.identify({
__typename: "messages",
id: message.id
});
if (messageCacheId) {
client.cache.evict({ id: messageCacheId });
}
});
}
// Evict the conversation itself
client.cache.evict({ id: cacheId });
client.cache.gc(); // Trigger garbage collection to clean up unused entries
return;
}
client.cache.modify({
id: cacheId,
fields: {