From 252ee99b36f16c3ac8e145ac47df47852080007f Mon Sep 17 00:00:00 2001 From: James Acklin Date: Thu, 21 Nov 2024 22:06:13 -0500 Subject: [PATCH] db: handle channel membership changes to live-update unjoined channels --- packages/shared/src/db/changeListener.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/shared/src/db/changeListener.ts b/packages/shared/src/db/changeListener.ts index 8b777a5e71..c6efab2ee5 100644 --- a/packages/shared/src/db/changeListener.ts +++ b/packages/shared/src/db/changeListener.ts @@ -47,4 +47,12 @@ export function handleChange({ queryKey: ['post', row.thread_id], }); } + + // Handle channel membership changes + if (table === 'channels' && row) { + // If currentUserIsMember changed, invalidate unjoined channels query + queryClient.invalidateQueries({ + queryKey: ['unjoinedChannels', row.group_id], + }); + } }