import { useSecondaryPage } from '@/PageManager' import BookmarkList from '@/components/BookmarkList' import PostEditor from '@/components/PostEditor' import RelayInfo from '@/components/RelayInfo' import { Button } from '@/components/ui/button' import PrimaryPageLayout from '@/layouts/PrimaryPageLayout' import { toSearch } from '@/lib/link' import { useFeed } from '@/providers/FeedProvider' import { useNostr } from '@/providers/NostrProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { TPageRef } from '@/types' import { Info, PencilLine, Search } from 'lucide-react' import { Dispatch, forwardRef, SetStateAction, useEffect, useImperativeHandle, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import FeedButton from './FeedButton' import FollowingFeed from './FollowingFeed' import RelaysFeed from './RelaysFeed' const NoteListPage = forwardRef((_, ref) => { const { t } = useTranslation() const layoutRef = useRef(null) const { pubkey, checkLogin } = useNostr() const { feedInfo, relayUrls, isReady } = useFeed() const [showRelayDetails, setShowRelayDetails] = useState(false) useImperativeHandle(ref, () => layoutRef.current) useEffect(() => { if (layoutRef.current) { layoutRef.current.scrollToTop('instant') } }, [JSON.stringify(relayUrls), feedInfo]) let content: React.ReactNode = null if (!isReady) { content =
{t('loading...')}
} else if (feedInfo.feedType === 'following' && !pubkey) { content = (
) } else if (feedInfo.feedType === 'bookmarks') { if (!pubkey) { content = (
) } else { content = } } else if (feedInfo.feedType === 'following') { content = } else { content = ( <> {showRelayDetails && feedInfo.feedType === 'relay' && !!feedInfo.id && ( )} ) } return ( } displayScrollToTopButton > {content} ) }) NoteListPage.displayName = 'NoteListPage' export default NoteListPage function NoteListPageTitlebar({ layoutRef, showRelayDetails, setShowRelayDetails }: { layoutRef?: React.RefObject showRelayDetails?: boolean setShowRelayDetails?: Dispatch> }) { const { isSmallScreen } = useScreenSize() return (
{setShowRelayDetails && ( )} {isSmallScreen && ( <> )}
) } function PostButton() { const { checkLogin } = useNostr() const [open, setOpen] = useState(false) return ( <> ) } function SearchButton() { const { push } = useSecondaryPage() return ( ) }