import LibraryPublicationGrid from '@/components/Library/LibraryPublicationGrid' import LibrarySearchBar from '@/components/Library/LibrarySearchBar' import { RefreshButton } from '@/components/RefreshButton' import { Button } from '@/components/ui/button' import PrimaryPageLayout, { TPrimaryPageLayoutRef } from '@/layouts/PrimaryPageLayout' import { useLibraryPublications } from '@/hooks/useLibraryPublications' import { LIBRARY_PAGE_SIZE } from '@/lib/library-publication-index' import { usePrimaryPage } from '@/contexts/primary-page-context' import { TPageRef } from '@/types' import { BookOpen } from 'lucide-react' import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react' import { useTranslation } from 'react-i18next' const LibraryPage = forwardRef((_props, ref) => { const { t } = useTranslation() const { current, display } = usePrimaryPage() const isActive = useMemo(() => current === 'library' && display, [current, display]) const layoutRef = useRef(null) const { entries, searchQuery, setSearchQuery, searchAxis, setSearchAxis, showOnlyMine, setShowOnlyMine, mineFilterLoading, loading, engagementLoading, searchLoading, relaySearchLoading, error, allIndexCount, topLevelCount, refresh, searchOnRelays, hasIndexData, loadMoreFeed, defaultFeedHasMore, feedTotalCount } = useLibraryPublications(isActive) useImperativeHandle( ref, () => ({ scrollToTop: (behavior: ScrollBehavior = 'smooth') => layoutRef.current?.scrollToTop(behavior), refresh }), [refresh] ) const statusLine = !loading && !error ? t('Library status line', { shown: entries.length, topLevel: topLevelCount, total: allIndexCount }) : null return ( } displayScrollToTopButton >
void searchOnRelays()} relaySearchLoading={relaySearchLoading} disabled={loading && !hasIndexData} />
{error ? (
{error}
) : null} {loading ? (

{t('Library loading')}

) : engagementLoading ? (

{t('Library engagement loading')}

) : searchLoading ? (

{t('Library search loading')}

) : mineFilterLoading ? (

{t('Library mine filter loading')}

) : relaySearchLoading ? (

{t('Library relay search loading')}

) : null} {statusLine ? (

{statusLine}

) : null} {defaultFeedHasMore ? (
) : null}
) }) LibraryPage.displayName = 'LibraryPage' export default LibraryPage function LibraryPageTitlebar({ onRefresh }: { onRefresh: () => void }) { const { t } = useTranslation() return (
{t('Library page title')}
) }