mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-04 00:48:52 +02:00
⚡️ Quicker UI updates when adding participant (#1045)
This commit is contained in:
parent
f9d5d0a9bc
commit
fe856d6c7d
1 changed files with 11 additions and 1 deletions
|
@ -19,7 +19,17 @@ export const useAddParticipantMutation = () => {
|
|||
const queryClient = trpc.useUtils();
|
||||
|
||||
return trpc.polls.participants.add.useMutation({
|
||||
onSuccess: (_, { pollId, name, email }) => {
|
||||
onSuccess: (newParticipant, input) => {
|
||||
const { pollId, name, email } = newParticipant;
|
||||
queryClient.polls.participants.list.setData(
|
||||
{ pollId },
|
||||
(existingParticipants = []) => {
|
||||
return [
|
||||
{ ...newParticipant, votes: input.votes },
|
||||
...existingParticipants,
|
||||
];
|
||||
},
|
||||
);
|
||||
queryClient.polls.participants.list.invalidate({ pollId });
|
||||
posthog?.capture("add participant", {
|
||||
pollId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue