From 50e4084b766630b0d0f1f9a7fdfa24cd972df1e5 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Sat, 28 Sep 2024 13:51:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Rate=20limit=20comments?= =?UTF-8?q?=20(#1363)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/discussion/discussion.tsx | 21 ++++++++++++------- apps/web/src/trpc/routers/polls/comments.ts | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/web/src/components/discussion/discussion.tsx b/apps/web/src/components/discussion/discussion.tsx index c3443e6d2..eeec4a455 100644 --- a/apps/web/src/components/discussion/discussion.tsx +++ b/apps/web/src/components/discussion/discussion.tsx @@ -15,6 +15,7 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@rallly/ui/dropdown-menu"; +import { useToast } from "@rallly/ui/hooks/use-toast"; import { Icon } from "@rallly/ui/icon"; import { Input } from "@rallly/ui/input"; import { Textarea } from "@rallly/ui/textarea"; @@ -77,13 +78,6 @@ function NewCommentForm({ const queryClient = trpc.useUtils(); - const addComment = trpc.polls.comments.add.useMutation({ - onSuccess: () => { - queryClient.polls.comments.invalidate(); - posthog?.capture("created comment"); - }, - }); - const session = useUser(); const { register, reset, control, handleSubmit, formState } = @@ -93,7 +87,20 @@ function NewCommentForm({ content: "", }, }); + const { toast } = useToast(); + const addComment = trpc.polls.comments.add.useMutation({ + onSuccess: () => { + queryClient.polls.comments.invalidate(); + posthog?.capture("created comment"); + }, + onError: (error) => { + toast({ + title: "Error", + description: error.message, + }); + }, + }); return (