From b50df69cf3499eb8facea1475b99b85362468681 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 12 Mar 2025 15:55:04 +0100 Subject: [PATCH] fix(pending post): page could redirect to "not found" if pending post failed --- src/views/pending-post/pending-post.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/views/pending-post/pending-post.tsx b/src/views/pending-post/pending-post.tsx index 0aa2be50..7c285b98 100644 --- a/src/views/pending-post/pending-post.tsx +++ b/src/views/pending-post/pending-post.tsx @@ -14,10 +14,13 @@ const PendingPost = () => { const isValidAccountCommentIndex = !accountCommentIndex || + // Check if it's a valid positive integer (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0 && - accountComments?.length > 0 && - parseInt(accountCommentIndex) < accountComments.length); + Number.isInteger(parseFloat(accountCommentIndex)) && + // Allow index to be at most 1 position beyond the current length + // This handles the case where a new post is being created + (accountComments?.length === 0 || parseInt(accountCommentIndex) <= accountComments.length)); useEffect(() => { if (!isValidAccountCommentIndex) {