From 811405dea9d72ef41a115d7a0e110c57b1040f89 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 10 Jul 2024 17:51:58 +0200 Subject: [PATCH] fix(subplebbit stats): stats box appeared even if stats are undefined --- src/components/subplebbit-stats/subplebbit-stats.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/subplebbit-stats/subplebbit-stats.tsx b/src/components/subplebbit-stats/subplebbit-stats.tsx index 42de8e08..4b527b46 100644 --- a/src/components/subplebbit-stats/subplebbit-stats.tsx +++ b/src/components/subplebbit-stats/subplebbit-stats.tsx @@ -15,16 +15,16 @@ const SubplebbitStats = () => { const subplebbit = useSubplebbit({ subplebbitAddress }); const { address, createdAt } = subplebbit || {}; + const stats = useSubplebbitStats({ subplebbitAddress: address }); + const [showStats, setShowStats] = useState(true); + const location = useLocation(); const isInDescriptionView = isDescriptionView(location.pathname, params); const isInRulesView = isRulesView(location.pathname, params); const comment = useComment({ commentCid: params?.commentCid }); const { deleted, locked, removed } = comment || {}; - const hideStats = deleted || locked || removed || isInDescriptionView || isInRulesView; - - const stats = useSubplebbitStats({ subplebbitAddress: address }); - const [showStats, setShowStats] = useState(true); + const hideStats = !stats.allPostCount || deleted || locked || removed || isInDescriptionView || isInRulesView; const unixToMMDDYYYY = (timestamp: number) => { const date = new Date(timestamp * 1000);