From 364240c8dec8a4a2dc6fff7b4f10f8953360032a Mon Sep 17 00:00:00 2001 From: Mohammed Zafeeruddin <121102547+Zafeeruddin@users.noreply.github.com> Date: Sat, 5 Oct 2024 04:30:35 +0530 Subject: [PATCH] Fixed bugs of voting, editor clicks, replies (#1331) --- src/actions/commentVote/index.ts | 4 ++-- src/actions/commentVote/schema.ts | 1 + src/components/Sidebar.tsx | 3 +-- src/components/posts/PostCard.tsx | 19 ++++++++++++---- src/components/posts/form/form-vote.tsx | 30 ++++++++++++------------- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/actions/commentVote/index.ts b/src/actions/commentVote/index.ts index 53be3d0c3..069d38134 100644 --- a/src/actions/commentVote/index.ts +++ b/src/actions/commentVote/index.ts @@ -20,7 +20,7 @@ const voteHandler = async ( return { error: 'Unauthorized' }; } - const { questionId, answerId, commentId, voteType, currentPath } = data; + const { questionId, answerId, commentId, voteType, currentPath, slug } = data; if (!questionId && !answerId && !commentId) { return { error: 'No valid target specified.' }; @@ -142,7 +142,7 @@ const voteHandler = async ( } if (currentPath) { - revalidatePath(currentPath); + revalidatePath(`${currentPath}/${slug}`); } return { data: updatedEntity }; diff --git a/src/actions/commentVote/schema.ts b/src/actions/commentVote/schema.ts index 28cb1552a..9e1b6bb67 100644 --- a/src/actions/commentVote/schema.ts +++ b/src/actions/commentVote/schema.ts @@ -7,4 +7,5 @@ export const VoteHandleSchema = z.object({ answerId: z.number().optional(), voteType: z.nativeEnum(VoteType), currentPath: z.string(), + slug: z.string(), }); diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 61d7eac8e..d113df33b 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -206,8 +206,7 @@ export function Sidebar({ variants={sidebarVariants} className="fixed right-0 top-0 z-[99999] flex h-screen w-full flex-col gap-4 overflow-y-auto rounded-r-lg border-l border-primary/10 bg-neutral-50 dark:bg-neutral-900 md:max-w-[30vw]" > -