From 1e44818b7a64d978b531b961c49aa53884fcf733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milind=20Mishra=20=E2=96=B2?= Date: Fri, 5 Jan 2024 20:11:33 +0530 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20update=20toast=20to?= =?UTF-8?q?=20top=20center?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/actions/message/index.ts | 2 -- frontend/app/layout.tsx | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/actions/message/index.ts b/frontend/actions/message/index.ts index 62b3a98..cd78c38 100644 --- a/frontend/actions/message/index.ts +++ b/frontend/actions/message/index.ts @@ -31,13 +31,11 @@ const rateLimit = (userId: string): boolean => { const userLimiter = userRateLimits.get(userId) ?? { timestamps: [] }; - userLimiter.timestamps = userLimiter.timestamps.filter( timestamp => now.getTime() - timestamp.getTime() < interval ); if (userLimiter.timestamps.length >= limit) { - return false; } diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index a5ebed6..2338ae3 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -24,8 +24,7 @@ export default function RootLayout({ - - + {children} From c7c4554fd7c968f48647fb28f74390faccbd3cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milind=20Mishra=20=E2=96=B2?= Date: Fri, 5 Jan 2024 20:45:10 +0530 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20add=20toast=20promise?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app/layout.tsx | 2 +- frontend/components/form/form-vote.tsx | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index 2338ae3..d32f468 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -24,7 +24,7 @@ export default function RootLayout({ - + {children} diff --git a/frontend/components/form/form-vote.tsx b/frontend/components/form/form-vote.tsx index de88166..b9111a5 100644 --- a/frontend/components/form/form-vote.tsx +++ b/frontend/components/form/form-vote.tsx @@ -31,19 +31,25 @@ const VoteForm: React.FC = ({ }) => { const { execute, fieldErrors, setFieldErrors } = useAction(updateVote, { onSuccess: (data) => { - toast.success( - `Question has "${data?.upVotes}" up votes and "${data?.downVotes}" down votes Now`, - ); + // toast(JSON.stringify(data)); }, onError: (error) => { toast.error(error); }, }); const handleDownVote = () => { - execute({ value: -1, questionId, answerId }); + toast.promise(execute({ value: -1, questionId, answerId }), { + loading: 'Downvoting...', + success: 'Question has been downvoted.', + error: 'Error', + }); }; const handleUpVote = () => { - execute({ value: 1, questionId, answerId }); + toast.promise(execute({ value: 1, questionId, answerId }), { + loading: 'Upvoting...', + success: 'Question has been upvoted.', + error: 'Error', + }); }; const userVoted = Boolean(votesArr.length);