Browse Source

fix: repeated subscription

imwald
codytseng 1 year ago
parent
commit
61b7743b77
  1. 4
      src/components/NoteList/index.tsx
  2. 10
      src/pages/secondary/ProfilePage/index.tsx

4
src/components/NoteList/index.tsx

@ -27,7 +27,7 @@ export default function NoteList({
}) { }) {
const { t } = useTranslation() const { t } = useTranslation()
const { signEvent, checkLogin } = useNostr() const { signEvent, checkLogin } = useNostr()
const { isFetching: isFetchingRelayInfo, areAlgoRelays } = useFetchRelayInfos(relayUrls) const { isFetching: isFetchingRelayInfo, areAlgoRelays } = useFetchRelayInfos([...relayUrls])
const [refreshCount, setRefreshCount] = useState(0) const [refreshCount, setRefreshCount] = useState(0)
const [timelineKey, setTimelineKey] = useState<string | undefined>(undefined) const [timelineKey, setTimelineKey] = useState<string | undefined>(undefined)
const [events, setEvents] = useState<Event[]>([]) const [events, setEvents] = useState<Event[]>([])
@ -54,7 +54,7 @@ export default function NoteList({
setHasMore(true) setHasMore(true)
const { closer, timelineKey } = await client.subscribeTimeline( const { closer, timelineKey } = await client.subscribeTimeline(
relayUrls, [...relayUrls],
noteFilter, noteFilter,
{ {
onEvents: (events, eosed) => { onEvents: (events, eosed) => {

10
src/pages/secondary/ProfilePage/index.tsx

@ -26,6 +26,10 @@ export default function ProfilePage({ id }: { id?: string }) {
const { profile, isFetching } = useFetchProfile(id) const { profile, isFetching } = useFetchProfile(id)
const { relayList, isFetching: isFetchingRelayInfo } = useFetchRelayList(profile?.pubkey) const { relayList, isFetching: isFetchingRelayInfo } = useFetchRelayList(profile?.pubkey)
const { relayUrls: currentRelayUrls } = useRelaySettings() const { relayUrls: currentRelayUrls } = useRelaySettings()
const relayUrls = useMemo(
() => relayList.write.slice(0, 4).concat(currentRelayUrls.slice(0, 1)),
[relayList, currentRelayUrls]
)
const { pubkey: accountPubkey } = useNostr() const { pubkey: accountPubkey } = useNostr()
const { followings: selfFollowings } = useFollowList() const { followings: selfFollowings } = useFollowList()
const { followings } = useFetchFollowings(profile?.pubkey) const { followings } = useFetchFollowings(profile?.pubkey)
@ -100,11 +104,7 @@ export default function ProfilePage({ id }: { id?: string }) {
</div> </div>
<Separator className="hidden sm:block mt-4 sm:my-4" /> <Separator className="hidden sm:block mt-4 sm:my-4" />
{!isFetchingRelayInfo && ( {!isFetchingRelayInfo && (
<NoteList <NoteList filter={{ authors: [pubkey] }} relayUrls={relayUrls} className="max-sm:mt-2" />
filter={{ authors: [pubkey] }}
relayUrls={relayList.write.slice(0, 5).concat(currentRelayUrls)}
className="max-sm:mt-2"
/>
)} )}
</SecondaryPageLayout> </SecondaryPageLayout>
) )

Loading…
Cancel
Save