mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-23 13:56:18 +02:00
♻️ Improve query invalidation (#659)
This commit is contained in:
parent
0ad5abb590
commit
5b6d8424af
6 changed files with 21 additions and 26 deletions
|
@ -25,23 +25,19 @@ interface CommentForm {
|
|||
|
||||
const Discussion: React.FunctionComponent = () => {
|
||||
const { dayjs } = useDayjs();
|
||||
const queryClient = trpc.useContext();
|
||||
const { t } = useTranslation("app");
|
||||
const { poll, admin } = usePoll();
|
||||
|
||||
const pollId = poll.id;
|
||||
|
||||
const { data: comments } = trpc.polls.comments.list.useQuery(
|
||||
{ pollId },
|
||||
{
|
||||
refetchInterval: 10000, // refetch every 10 seconds
|
||||
trpc: {},
|
||||
},
|
||||
);
|
||||
const { data: comments } = trpc.polls.comments.list.useQuery({ pollId });
|
||||
const posthog = usePostHog();
|
||||
|
||||
const queryClient = trpc.useContext();
|
||||
|
||||
const addComment = trpc.polls.comments.add.useMutation({
|
||||
onSuccess: () => {
|
||||
queryClient.polls.comments.invalidate();
|
||||
posthog?.capture("created comment");
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue