feat: add support for commenting and reacting on external content
This commit is contained in:
parent
5ba5c26fcd
commit
0bb62dd3fb
76 changed files with 1635 additions and 639 deletions
|
|
@ -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
15
src/hooks/useStuff.tsx
Normal 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
|
||||
}
|
||||
9
src/hooks/useStuffStatsById.tsx
Normal file
9
src/hooks/useStuffStatsById.tsx
Normal 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)
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue