diff --git a/components/right-sidebar.tsx b/components/right-sidebar.tsx index ddc6a0c..b5ff9ee 100644 --- a/components/right-sidebar.tsx +++ b/components/right-sidebar.tsx @@ -15,12 +15,16 @@ const MastodonFeed = dynamic(() => import('./mastodon-feed').then(mod => ({ defa ssr: false, }); -export function RightSidebar() { - const [shouldLoadFeed, setShouldLoadFeed] = useState(false); +/** Shared sidebar content for desktop aside and mobile drawer */ +export function RightSidebarContent({ forceLoadFeed = false }: { forceLoadFeed?: boolean }) { + const [shouldLoadFeed, setShouldLoadFeed] = useState(forceLoadFeed); const feedRef = useRef(null); useEffect(() => { - // Use Intersection Observer to lazy load MastodonFeed when sidebar is visible + if (forceLoadFeed) { + setShouldLoadFeed(true); + return; + } if (!feedRef.current) return; const observer = new IntersectionObserver( @@ -30,13 +34,12 @@ export function RightSidebar() { observer.disconnect(); } }, - { rootMargin: '100px' } // Start loading 100px before it's visible + { rootMargin: '100px' } ); observer.observe(feedRef.current); - return () => observer.disconnect(); - }, []); + }, [forceLoadFeed]); const tags = getAllTagsWithCount().slice(0, 5); @@ -68,9 +71,8 @@ export function RightSidebar() { ].filter(Boolean) as { key: string; href: string; icon: any; label: string }[]; return ( -