Skip to content
Snippets Groups Projects
Unverified Commit 6bce20a3 authored by Guilherme Gazzo's avatar Guilherme Gazzo Committed by GitHub
Browse files

fix: Message sent triggering thread subscriptions multiple times (#29546)

parent c43b745f
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/meteor': minor
---
fix: Message sent triggering thread subscriptions multiple times
......@@ -82,8 +82,9 @@ export const useThreadMainMessageQuery = (
useEffect(() => {
return () => {
unsubscribeRef.current?.();
unsubscribeRef.current = undefined;
};
}, []);
}, [tmid]);
return useQuery(
['rooms', room._id, 'threads', tmid, 'main-message'] as const,
......@@ -96,17 +97,17 @@ export const useThreadMainMessageQuery = (
throw new Error('Invalid main message');
}
unsubscribeRef.current?.();
unsubscribeRef.current = subscribeToMessage(mainMessage, {
onMutate: () => {
queryClient.invalidateQueries(queryKey, { exact: true });
},
onDelete: () => {
onDelete?.();
queryClient.invalidateQueries(queryKey, { exact: true });
},
});
unsubscribeRef.current =
unsubscribeRef.current ||
subscribeToMessage(mainMessage, {
onMutate: () => {
queryClient.invalidateQueries(queryKey, { exact: true });
},
onDelete: () => {
onDelete?.();
queryClient.invalidateQueries(queryKey, { exact: true });
},
});
return mainMessage;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment