From 2946ede5ac4e6a7365741c56699fd0fdabcc0d7c Mon Sep 17 00:00:00 2001 From: Gigi Date: Tue, 14 Oct 2025 11:57:04 +0200 Subject: [PATCH] fix: filter out blog posts with far-future publication dates - Add filteredBlogPosts useMemo to exclude posts with unreasonable dates - Allow 1 day into future for clock skew tolerance - Prevents spam/error posts with dates like '53585 years from now' - Uses published_at tag or event.created_at as fallback --- src/components/Explore.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/Explore.tsx b/src/components/Explore.tsx index 4f4a5d4a..5a7d91c3 100644 --- a/src/components/Explore.tsx +++ b/src/components/Explore.tsx @@ -243,16 +243,25 @@ const Explore: React.FC = ({ relayPool, activeTab: propActiveTab } return classifyHighlights(highlights, activeAccount?.pubkey, followedPubkeys) }, [highlights, activeAccount?.pubkey, followedPubkeys]) + // Filter out blog posts with unreasonable future dates (allow 1 day for clock skew) + const filteredBlogPosts = useMemo(() => { + const maxFutureTime = Date.now() / 1000 + (24 * 60 * 60) // 1 day from now + return blogPosts.filter(post => { + const publishedTime = post.published || post.event.created_at + return publishedTime <= maxFutureTime + }) + }, [blogPosts]) + const renderTabContent = () => { switch (activeTab) { case 'writings': - return blogPosts.length === 0 ? ( + return filteredBlogPosts.length === 0 ? (

No blog posts found yet.

) : (
- {blogPosts.map((post) => ( + {filteredBlogPosts.map((post) => ( t[0] === 'd')?.[1]}`} post={post}