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

View File

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

View File

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

View File

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

View File

@@ -91,7 +91,8 @@ class StorageService {
this.activeRelaySetId = activeRelaySetId
} else {
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
}
}