From 7d4d7642fdcfe684076dbb4d13f48e36ac470071 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 5 Jun 2026 16:39:23 +0300 Subject: [PATCH] [Chat] Sync single-convo cache on chat lock firehose events (#10746) Co-authored-by: Claude Opus 4.8 (1M context) --- .../queries/messages/list-conversations.tsx | 63 +++++-------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/src/state/queries/messages/list-conversations.tsx b/src/state/queries/messages/list-conversations.tsx index f026e57d33..dadf30bcdf 100644 --- a/src/state/queries/messages/list-conversations.tsx +++ b/src/state/queries/messages/list-conversations.tsx @@ -418,67 +418,34 @@ export function ListConvosProviderInner({ })), ) } else if (ChatBskyConvoDefs.isLogLockConvo(log)) { - queryClient.setQueriesData( - {queryKey: [RQKEY_ROOT]}, - (old?: ConvoListQueryData) => - optimisticUpdate(log.convoId, old, convo => { - if (ChatBskyConvoDefs.isGroupConvo(convo.kind)) { - return { - ...convo, - kind: { - ...convo.kind, - lockStatus: 'locked', - }, - rev: log.rev, - } - } - return { + mutateConvoView(log.convoId, convo => + ChatBskyConvoDefs.isGroupConvo(convo.kind) + ? { ...convo, + kind: {...convo.kind, lockStatus: 'locked'}, rev: log.rev, } - }), + : {...convo, rev: log.rev}, ) } else if (ChatBskyConvoDefs.isLogUnlockConvo(log)) { - queryClient.setQueriesData( - {queryKey: [RQKEY_ROOT]}, - (old?: ConvoListQueryData) => - optimisticUpdate(log.convoId, old, convo => { - if (ChatBskyConvoDefs.isGroupConvo(convo.kind)) { - return { - ...convo, - kind: { - ...convo.kind, - lockStatus: 'unlocked', - }, - rev: log.rev, - } - } - return { + mutateConvoView(log.convoId, convo => + ChatBskyConvoDefs.isGroupConvo(convo.kind) + ? { ...convo, + kind: {...convo.kind, lockStatus: 'unlocked'}, rev: log.rev, } - }), + : {...convo, rev: log.rev}, ) } else if (ChatBskyConvoDefs.isLogLockConvoPermanently(log)) { - queryClient.setQueriesData( - {queryKey: [RQKEY_ROOT]}, - (old?: ConvoListQueryData) => - optimisticUpdate(log.convoId, old, convo => { - if (ChatBskyConvoDefs.isGroupConvo(convo.kind)) { - return { - ...convo, - kind: { - ...convo.kind, - lockStatus: 'locked-permanently', - }, - rev: log.rev, - } - } - return { + mutateConvoView(log.convoId, convo => + ChatBskyConvoDefs.isGroupConvo(convo.kind) + ? { ...convo, + kind: {...convo.kind, lockStatus: 'locked-permanently'}, rev: log.rev, } - }), + : {...convo, rev: log.rev}, ) } else if ( ChatBskyConvoDefs.isLogCreateJoinLink(log) ||