fix: 🐛

This commit is contained in:
codytseng
2025-08-12 11:05:24 +08:00
parent c6a5157fe7
commit 4a946e4ab0
9 changed files with 310 additions and 211 deletions

View File

@@ -8,7 +8,7 @@ import { fetchPubkeysFromDomain, getWellKnownNip05Url } from '@/lib/nip05'
import { useSecondaryPage } from '@/PageManager'
import { useNostr } from '@/providers/NostrProvider'
import client from '@/services/client.service'
import { TNormalFeedSubRequest } from '@/types'
import { TFeedSubRequest } from '@/types'
import { UserRound } from 'lucide-react'
import React, { forwardRef, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -29,7 +29,7 @@ const NoteListPage = forwardRef(({ index }: { index?: number }, ref) => {
}
| null
>(null)
const [subRequests, setSubRequests] = useState<TNormalFeedSubRequest[]>([])
const [subRequests, setSubRequests] = useState<TFeedSubRequest[]>([])
useEffect(() => {
const init = async () => {
@@ -94,6 +94,8 @@ const NoteListPage = forwardRef(({ index }: { index?: number }, ref) => {
{pubkeys.length.toLocaleString()} <UserRound />
</Button>
)
} else {
setSubRequests([])
}
return
}
@@ -102,7 +104,7 @@ const NoteListPage = forwardRef(({ index }: { index?: number }, ref) => {
}, [])
let content: React.ReactNode = null
if (data?.type === 'domain' && setSubRequests.length === 0) {
if (data?.type === 'domain' && subRequests.length === 0) {
content = (
<div className="text-center w-full py-10">
<span className="text-muted-foreground">

View File

@@ -0,0 +1,99 @@
import NoteList, { TNoteListRef } from '@/components/NoteList'
import Tabs from '@/components/Tabs'
import { BIG_RELAY_URLS } from '@/constants'
import { useNostr } from '@/providers/NostrProvider'
import client from '@/services/client.service'
import storage from '@/services/local-storage.service'
import { TFeedSubRequest, TNoteListMode } from '@/types'
import { useEffect, useMemo, useRef, useState } from 'react'
export default function ProfileFeed({
pubkey,
topSpace = 0
}: {
pubkey: string
topSpace?: number
}) {
const { pubkey: myPubkey } = useNostr()
const [listMode, setListMode] = useState<TNoteListMode>(() => storage.getNoteListMode())
const noteListRef = useRef<TNoteListRef>(null)
const [subRequests, setSubRequests] = useState<TFeedSubRequest[]>([])
const tabs = useMemo(() => {
const _tabs = [
{ value: 'posts', label: 'Notes' },
{ value: 'postsAndReplies', label: 'Replies' }
]
if (myPubkey && myPubkey !== pubkey) {
_tabs.push({ value: 'you', label: 'YouTabName' })
}
return _tabs
}, [myPubkey, pubkey])
useEffect(() => {
const init = async () => {
if (listMode === 'you') {
if (!myPubkey) {
setSubRequests([])
return
}
const [relayList, myRelayList] = await Promise.all([
client.fetchRelayList(pubkey),
client.fetchRelayList(myPubkey)
])
setSubRequests([
{
urls: myRelayList.write.concat(BIG_RELAY_URLS).slice(0, 5),
filter: {
authors: [myPubkey],
'#p': [pubkey]
}
},
{
urls: relayList.write.concat(BIG_RELAY_URLS).slice(0, 5),
filter: {
authors: [pubkey],
'#p': [myPubkey]
}
}
])
return
}
const relayList = await client.fetchRelayList(pubkey)
setSubRequests([
{
urls: relayList.write.concat(BIG_RELAY_URLS).slice(0, 8),
filter: {
authors: [pubkey]
}
}
])
}
init()
}, [pubkey, listMode])
const handleListModeChange = (mode: TNoteListMode) => {
setListMode(mode)
setTimeout(() => {
noteListRef.current?.scrollToTop()
}, 0)
}
return (
<>
<Tabs
value={listMode}
tabs={tabs}
onTabChange={(listMode) => {
handleListModeChange(listMode as TNoteListMode)
}}
threshold={Math.max(800, topSpace)}
/>
<NoteList ref={noteListRef} subRequests={subRequests} hideReplies={listMode === 'posts'} />
</>
)
}

View File

@@ -1,13 +1,12 @@
import Collapsible from '@/components/Collapsible'
import FollowButton from '@/components/FollowButton'
import Nip05 from '@/components/Nip05'
import Feed from '@/components/Feed'
import NpubQrCode from '@/components/NpubQrCode'
import ProfileAbout from '@/components/ProfileAbout'
import ProfileBanner from '@/components/ProfileBanner'
import ProfileOptions from '@/components/ProfileOptions'
import ProfileZapButton from '@/components/ProfileZapButton'
import PubkeyCopy from '@/components/PubkeyCopy'
import NpubQrCode from '@/components/NpubQrCode'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
import { Button } from '@/components/ui/button'
import { Skeleton } from '@/components/ui/skeleton'
@@ -25,6 +24,7 @@ import { useTranslation } from 'react-i18next'
import NotFoundPage from '../NotFoundPage'
import FollowedBy from './FollowedBy'
import Followings from './Followings'
import ProfileFeed from './ProfileFeed'
import Relays from './Relays'
const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref) => {
@@ -193,13 +193,7 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number },
</div>
</div>
</div>
<Feed
author={pubkey}
className="mt-2"
filterMutedNotes={false}
topSpace={topContainerHeight + 100}
skipTrustCheck
/>
<ProfileFeed pubkey={pubkey} topSpace={topContainerHeight + 100} />
</SecondaryPageLayout>
)
})