Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🐛 Fix race condition (#1625)
Luke Velladd719620ffb4
diff --git a/apps/web/src/components/create-poll.tsx b/apps/web/src/components/create-poll.tsxindex a06ddfe65..2665b5688 100644--- a/apps/web/src/components/create-poll.tsx+++ b/apps/web/src/components/create-poll.tsx@@ -69,13 +69,6 @@ export const CreatePoll: React.FunctionComponent = () => {const posthog = usePostHog();const createPoll = trpc.polls.create.useMutation({networkMode: "always",- onMutate: async () => {- if (session.status !== "authenticated") {- await signIn("guest", {- redirect: false,- });- }- },onError: (error) => {if (error.data?.code === "BAD_REQUEST") {toast({@@ -91,6 +84,11 @@ export const CreatePoll: React.FunctionComponent = () => {<formonSubmit={form.handleSubmit(async (formData) => {const title = required(formData?.title);+ if (session.status !== "authenticated") {+ await signIn("guest", {+ redirect: false,+ });+ }await createPoll.mutateAsync({title: title,diff --git a/apps/web/src/components/discussion/discussion.tsx b/apps/web/src/components/discussion/discussion.tsxindex 2e418f3c5..098764902 100644--- a/apps/web/src/components/discussion/discussion.tsx+++ b/apps/web/src/components/discussion/discussion.tsx@@ -84,13 +84,6 @@ function NewCommentForm({const { toast } = useToast();const addComment = trpc.polls.comments.add.useMutation({- onMutate: async () => {- if (session.status !== "authenticated") {- await signIn("guest", {- redirect: false,- });- }- },onSuccess: () => {posthog?.capture("created comment");},@@ -105,6 +98,11 @@ function NewCommentForm({<formclassName="w-full space-y-2.5"onSubmit={handleSubmit(async ({ authorName, content }) => {+ if (session.status !== "authenticated") {+ await signIn("guest", {+ redirect: false,+ });+ }await addComment.mutateAsync({ authorName, content, pollId });reset({ authorName, content: "" });onSubmit?.();