fix: 🐛

This commit is contained in:
codytseng
2025-01-13 23:56:41 +08:00
parent c62a82f673
commit 6bc2fde314
5 changed files with 10 additions and 5 deletions

View File

@@ -122,7 +122,7 @@ export default function NoteList({
const options = { const options = {
root: null, root: null,
rootMargin: '10px', rootMargin: '10px',
threshold: 1 threshold: 0.1
} }
const observerInstance = new IntersectionObserver((entries) => { const observerInstance = new IntersectionObserver((entries) => {
@@ -142,7 +142,7 @@ export default function NoteList({
observerInstance.unobserve(currentBottomRef) observerInstance.unobserve(currentBottomRef)
} }
} }
}, [refreshing, hasMore, events, timelineKey]) }, [refreshing, hasMore, events, timelineKey, bottomRef])
const loadMore = async () => { const loadMore = async () => {
if (!timelineKey || refreshing) return if (!timelineKey || refreshing) return

View File

@@ -35,6 +35,9 @@ export function userIdToPubkey(userId: string) {
if (userId.startsWith('npub1')) { if (userId.startsWith('npub1')) {
const { data } = nip19.decode(userId as `npub1${string}`) const { data } = nip19.decode(userId as `npub1${string}`)
return data return data
} else if (userId.startsWith('nprofile1')) {
const { data } = nip19.decode(userId as `nprofile1${string}`)
return data.pubkey
} }
return userId return userId
} }

View File

@@ -57,6 +57,7 @@ export function FeedProvider({ children }: { children: React.ReactNode }) {
if (feedType === 'following') { if (feedType === 'following') {
return await switchFeed('following', { pubkey }) return await switchFeed('following', { pubkey })
} else { } else {
console.log('activeRelaySetId', activeRelaySetId)
await switchFeed('relays', { activeRelaySetId }) await switchFeed('relays', { activeRelaySetId })
} }
} }

View File

@@ -4,7 +4,7 @@ import {
getProfileFromProfileEvent, getProfileFromProfileEvent,
getRelayListFromRelayListEvent getRelayListFromRelayListEvent
} from '@/lib/event' } from '@/lib/event'
import { userIdToPubkey } from '@/lib/pubkey' import { formatPubkey, userIdToPubkey } from '@/lib/pubkey'
import { TDraftEvent, TProfile, TRelayInfo, TRelayList } from '@/types' import { TDraftEvent, TProfile, TRelayInfo, TRelayList } from '@/types'
import { sha256 } from '@noble/hashes/sha2' import { sha256 } from '@noble/hashes/sha2'
import DataLoader from 'dataloader' import DataLoader from 'dataloader'
@@ -393,7 +393,7 @@ class ClientService extends EventTarget {
try { try {
const pubkey = userIdToPubkey(id) const pubkey = userIdToPubkey(id)
return { pubkey, username: pubkey } return { pubkey, username: formatPubkey(pubkey) }
} catch { } catch {
return undefined return undefined
} }

View File

@@ -91,7 +91,8 @@ class StorageService {
this.activeRelaySetId = activeRelaySetId this.activeRelaySetId = activeRelaySetId
} else { } else {
this.relaySets = JSON.parse(relaySetsStr) this.relaySets = JSON.parse(relaySetsStr)
this.activeRelaySetId = window.localStorage.getItem(StorageKey.ACTIVE_RELAY_SET_ID) ?? null const activeRelaySetIdStr = window.localStorage.getItem(StorageKey.ACTIVE_RELAY_SET_ID)
this.activeRelaySetId = activeRelaySetIdStr ? JSON.parse(activeRelaySetIdStr) : null
} }
} }