refactor: move bookmarks entry location
This commit is contained in:
parent
a847c4dc56
commit
5c2a016d4b
13 changed files with 95 additions and 69 deletions
35
src/pages/primary/BookmarkPage/index.tsx
Normal file
35
src/pages/primary/BookmarkPage/index.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import BookmarkList from '@/components/BookmarkList'
|
||||
import PrimaryPageLayout from '@/layouts/PrimaryPageLayout'
|
||||
import { TPageRef } from '@/types'
|
||||
import { BookmarkIcon } from 'lucide-react'
|
||||
import { forwardRef, useImperativeHandle, useRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const BookmarkPage = forwardRef((_, ref) => {
|
||||
const layoutRef = useRef<TPageRef>(null)
|
||||
useImperativeHandle(ref, () => layoutRef.current)
|
||||
|
||||
return (
|
||||
<PrimaryPageLayout
|
||||
pageName="bookmark"
|
||||
ref={layoutRef}
|
||||
titlebar={<BookmarkPageTitlebar />}
|
||||
displayScrollToTopButton
|
||||
>
|
||||
<BookmarkList />
|
||||
</PrimaryPageLayout>
|
||||
)
|
||||
})
|
||||
BookmarkPage.displayName = 'BookmarkPage'
|
||||
export default BookmarkPage
|
||||
|
||||
function BookmarkPageTitlebar() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="flex gap-2 items-center h-full pl-3">
|
||||
<BookmarkIcon />
|
||||
<div className="text-lg font-semibold">{t('Bookmarks')}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
import AccountManager from '@/components/AccountManager'
|
||||
import LoginDialog from '@/components/LoginDialog'
|
||||
import LogoutDialog from '@/components/LogoutDialog'
|
||||
import PubkeyCopy from '@/components/PubkeyCopy'
|
||||
import NpubQrCode from '@/components/NpubQrCode'
|
||||
import PubkeyCopy from '@/components/PubkeyCopy'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import { SimpleUserAvatar } from '@/components/UserAvatar'
|
||||
import { SimpleUsername } from '@/components/Username'
|
||||
import PrimaryPageLayout from '@/layouts/PrimaryPageLayout'
|
||||
import { toProfile, toRelaySettings, toSettings, toWallet } from '@/lib/link'
|
||||
import { toBookmarks, toProfile, toRelaySettings, toSettings, toWallet } from '@/lib/link'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useSecondaryPage } from '@/PageManager'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import {
|
||||
ArrowDownUp,
|
||||
Bookmark,
|
||||
ChevronRight,
|
||||
LogOut,
|
||||
Server,
|
||||
|
|
@ -75,6 +76,9 @@ const MePage = forwardRef((_, ref) => {
|
|||
<Item onClick={() => push(toRelaySettings())}>
|
||||
<Server /> {t('Relays')}
|
||||
</Item>
|
||||
<Item onClick={() => push(toBookmarks())}>
|
||||
<Bookmark /> {t('Bookmarks')}
|
||||
</Item>
|
||||
<Item onClick={() => push(toWallet())}>
|
||||
<Wallet />
|
||||
{t('Wallet')}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { cn } from '@/lib/utils'
|
|||
import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider'
|
||||
import { useFeed } from '@/providers/FeedProvider'
|
||||
import { useScreenSize } from '@/providers/ScreenSizeProvider'
|
||||
import { BookmarkIcon, ChevronDown, Server, UsersRound } from 'lucide-react'
|
||||
import { ChevronDown, Server, UsersRound } from 'lucide-react'
|
||||
import { forwardRef, HTMLAttributes, useMemo, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
|
|
@ -62,9 +62,6 @@ const FeedSwitcherTrigger = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivEle
|
|||
if (feedInfo.feedType === 'following') {
|
||||
return t('Following')
|
||||
}
|
||||
if (feedInfo.feedType === 'bookmarks') {
|
||||
return t('Bookmarks')
|
||||
}
|
||||
if (relayUrls.length === 0) {
|
||||
return t('Choose a relay')
|
||||
}
|
||||
|
|
@ -82,13 +79,7 @@ const FeedSwitcherTrigger = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivEle
|
|||
ref={ref}
|
||||
{...props}
|
||||
>
|
||||
{feedInfo.feedType === 'following' ? (
|
||||
<UsersRound />
|
||||
) : feedInfo.feedType === 'bookmarks' ? (
|
||||
<BookmarkIcon />
|
||||
) : (
|
||||
<Server />
|
||||
)}
|
||||
{feedInfo.feedType === 'following' ? <UsersRound /> : <Server />}
|
||||
<div className="text-lg font-semibold truncate">{title}</div>
|
||||
<ChevronDown />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
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'
|
||||
|
|
@ -60,18 +59,6 @@ const NoteListPage = forwardRef((_, ref) => {
|
|||
</Button>
|
||||
</div>
|
||||
)
|
||||
} else if (feedInfo.feedType === 'bookmarks') {
|
||||
if (!pubkey) {
|
||||
content = (
|
||||
<div className="flex justify-center w-full">
|
||||
<Button size="lg" onClick={() => checkLogin()}>
|
||||
{t('Please login to view bookmarks')}
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
content = <BookmarkList />
|
||||
}
|
||||
} else if (feedInfo.feedType === 'following') {
|
||||
content = <FollowingFeed />
|
||||
} else {
|
||||
|
|
|
|||
16
src/pages/secondary/BookmarkPage/index.tsx
Normal file
16
src/pages/secondary/BookmarkPage/index.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import BookmarkList from '@/components/BookmarkList'
|
||||
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
|
||||
import { forwardRef } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const BookmarkPage = forwardRef(({ index }: { index?: number }, ref) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<SecondaryPageLayout index={index} title={t('Bookmarks')} displayScrollToTopButton ref={ref}>
|
||||
<BookmarkList />
|
||||
</SecondaryPageLayout>
|
||||
)
|
||||
})
|
||||
BookmarkPage.displayName = 'BookmarkPage'
|
||||
export default BookmarkPage
|
||||
Loading…
Add table
Add a link
Reference in a new issue