feat: add support for commenting and reacting on external content

This commit is contained in:
codytseng 2025-11-15 16:26:19 +08:00
parent 5ba5c26fcd
commit 0bb62dd3fb
76 changed files with 1635 additions and 639 deletions

View file

@ -1,9 +0,0 @@
import noteStats from '@/services/note-stats.service'
import { useSyncExternalStore } from 'react'
export function useNoteStatsById(noteId: string) {
return useSyncExternalStore(
(cb) => noteStats.subscribeNoteStats(noteId, cb),
() => noteStats.getNoteStats(noteId)
)
}

15
src/hooks/useStuff.tsx Normal file
View file

@ -0,0 +1,15 @@
import { getEventKey } from '@/lib/event'
import { Event } from 'nostr-tools'
import { useMemo } from 'react'
export function useStuff(stuff: Event | string) {
const resolvedStuff = useMemo(
() =>
typeof stuff === 'string'
? { event: undefined, externalContent: stuff, stuffKey: stuff }
: { event: stuff, externalContent: undefined, stuffKey: getEventKey(stuff) },
[stuff]
)
return resolvedStuff
}

View file

@ -0,0 +1,9 @@
import stuffStats from '@/services/stuff-stats.service'
import { useSyncExternalStore } from 'react'
export function useStuffStatsById(stuffKey: string) {
return useSyncExternalStore(
(cb) => stuffStats.subscribeStuffStats(stuffKey, cb),
() => stuffStats.getStuffStats(stuffKey)
)
}