From ebb5ae464f63ae10c461d3d179560db5b4042689 Mon Sep 17 00:00:00 2001 From: plebeius Date: Fri, 20 Feb 2026 14:46:41 +0800 Subject: [PATCH] fix(post): ensure OP user ID tooltip shows at least 1 post in board view --- src/components/post-desktop/post-desktop.tsx | 5 ++++- src/components/post-mobile/post-mobile.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 5de79636..8de309fb 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -223,7 +223,10 @@ const PostInfo = ({ return 0; } - return document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length; + const domCount = document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length; + // DOM-based count can be 0 on initial mount (before commit) or when parent isn't in DOM yet (e.g. Virtuoso board feed). + // The current post is always at least 1 when we're displaying it. + return Math.max(domCount, 1); }, [showUserID, deleted, removed, shortAddress, postCid, postReplyCount]); const { hidden } = useHide(post); diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index 824e6364..340efc54 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -189,7 +189,10 @@ const PostInfoAndMedia = ({ post, postReplyCount = 0, roles, threadNumber }: Pos return 0; } - return document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length; + const domCount = document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length; + // DOM-based count can be 0 on initial mount (before commit) or when parent isn't in DOM yet (e.g. Virtuoso board feed). + // The current post is always at least 1 when we're displaying it. + return Math.max(domCount, 1); }, [showUserID, deleted, removed, shortAddress, postCid, postReplyCount]); const userID = address && Plebbit.getShortAddress({ address }); // shortened to 8 chars for display; users can verify the full user ID via "Copy user ID" in the post menu to guard against spoofing