feat: 💨
This commit is contained in:
@@ -136,23 +136,6 @@ export default function ProfileFeed({
|
||||
init()
|
||||
}, [pubkey, listMode, search])
|
||||
|
||||
useEffect(() => {
|
||||
if (pubkey !== myPubkey) return
|
||||
|
||||
const handleNewEvent = (data: Event) => {
|
||||
const customEvent = data as CustomEvent<NostrEvent>
|
||||
const evt = customEvent.detail
|
||||
if (evt.pubkey !== pubkey) return
|
||||
|
||||
noteListRef.current?.refresh()
|
||||
}
|
||||
|
||||
client.addEventListener('newEvent', handleNewEvent)
|
||||
return () => {
|
||||
client.removeEventListener('newEvent', handleNewEvent)
|
||||
}
|
||||
}, [pubkey, myPubkey])
|
||||
|
||||
const handleListModeChange = (mode: TNoteListMode) => {
|
||||
setListMode(mode)
|
||||
noteListRef.current?.scrollToTop('smooth')
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
EventTemplate,
|
||||
Filter,
|
||||
kinds,
|
||||
matchFilters,
|
||||
Event as NEvent,
|
||||
nip19,
|
||||
Relay,
|
||||
@@ -470,8 +471,24 @@ class ClientService extends EventTarget {
|
||||
}
|
||||
})
|
||||
|
||||
const handleNewEventFromInternal = (data: Event) => {
|
||||
const customEvent = data as CustomEvent<NEvent>
|
||||
const evt = customEvent.detail
|
||||
if (!matchFilters(filters, evt)) return
|
||||
|
||||
const id = evt.id
|
||||
const have = _knownIds.has(id)
|
||||
if (have) return
|
||||
|
||||
_knownIds.add(id)
|
||||
onevent?.(evt)
|
||||
}
|
||||
|
||||
this.addEventListener('newEvent', handleNewEventFromInternal)
|
||||
|
||||
return {
|
||||
close: () => {
|
||||
this.removeEventListener('newEvent', handleNewEventFromInternal)
|
||||
subPromises.forEach((subPromise) => {
|
||||
subPromise
|
||||
.then((sub) => {
|
||||
|
||||
Reference in New Issue
Block a user