fix: 🐛
This commit is contained in:
@@ -8,6 +8,7 @@ import { useNoteStatsById } from '@/hooks/useNoteStatsById'
|
||||
import { createReactionDraftEvent } from '@/lib/draft-event'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import { useScreenSize } from '@/providers/ScreenSizeProvider'
|
||||
import { useUserTrust } from '@/providers/UserTrustProvider'
|
||||
import noteStatsService from '@/services/note-stats.service'
|
||||
import { Loader, SmilePlus } from 'lucide-react'
|
||||
import { Event } from 'nostr-tools'
|
||||
@@ -22,15 +23,19 @@ export default function LikeButton({ event }: { event: Event }) {
|
||||
const { t } = useTranslation()
|
||||
const { isSmallScreen } = useScreenSize()
|
||||
const { pubkey, publish, checkLogin } = useNostr()
|
||||
const { hideUntrustedInteractions, isUserTrusted } = useUserTrust()
|
||||
const [liking, setLiking] = useState(false)
|
||||
const [isEmojiReactionsOpen, setIsEmojiReactionsOpen] = useState(false)
|
||||
const [isPickerOpen, setIsPickerOpen] = useState(false)
|
||||
const noteStats = useNoteStatsById(event.id)
|
||||
const { myLastEmoji, likeCount } = useMemo(() => {
|
||||
const stats = noteStats || {}
|
||||
const like = stats.likes?.find((like) => like.pubkey === pubkey)
|
||||
return { myLastEmoji: like?.emoji, likeCount: stats.likes?.length }
|
||||
}, [noteStats, pubkey])
|
||||
const myLike = stats.likes?.find((like) => like.pubkey === pubkey)
|
||||
const likes = hideUntrustedInteractions
|
||||
? stats.likes?.filter((like) => isUserTrusted(like.pubkey))
|
||||
: stats.likes
|
||||
return { myLastEmoji: myLike?.emoji, likeCount: likes?.length }
|
||||
}, [noteStats, pubkey, hideUntrustedInteractions])
|
||||
|
||||
const like = async (emoji: string) => {
|
||||
checkLogin(async () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function ReplyButton({ event }: { event: Event }) {
|
||||
return repliesMap.get(event.id)?.events.filter((evt) => isUserTrusted(evt.pubkey)).length ?? 0
|
||||
}
|
||||
return repliesMap.get(event.id)?.events.length ?? 0
|
||||
}, [repliesMap, event.id, isUserTrusted])
|
||||
}, [repliesMap, event.id, hideUntrustedInteractions])
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
return (
|
||||
|
||||
@@ -12,6 +12,7 @@ import { getNoteBech32Id } from '@/lib/event'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useNostr } from '@/providers/NostrProvider'
|
||||
import { useScreenSize } from '@/providers/ScreenSizeProvider'
|
||||
import { useUserTrust } from '@/providers/UserTrustProvider'
|
||||
import noteStatsService from '@/services/note-stats.service'
|
||||
import { Loader, PencilLine, Repeat } from 'lucide-react'
|
||||
import { Event, kinds } from 'nostr-tools'
|
||||
@@ -23,6 +24,7 @@ import { formatCount } from './utils'
|
||||
export default function RepostButton({ event }: { event: Event }) {
|
||||
const { t } = useTranslation()
|
||||
const { isSmallScreen } = useScreenSize()
|
||||
const { hideUntrustedInteractions, isUserTrusted } = useUserTrust()
|
||||
const { publish, checkLogin, pubkey } = useNostr()
|
||||
const noteStats = useNoteStatsById(event.id)
|
||||
const [reposting, setReposting] = useState(false)
|
||||
@@ -30,10 +32,12 @@ export default function RepostButton({ event }: { event: Event }) {
|
||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
|
||||
const { repostCount, hasReposted } = useMemo(() => {
|
||||
return {
|
||||
repostCount: noteStats?.repostPubkeySet?.size,
|
||||
repostCount: hideUntrustedInteractions
|
||||
? noteStats?.reposts?.filter((repost) => isUserTrusted(repost.pubkey)).length
|
||||
: noteStats?.reposts?.length,
|
||||
hasReposted: pubkey ? noteStats?.repostPubkeySet?.has(pubkey) : false
|
||||
}
|
||||
}, [noteStats, event.id])
|
||||
}, [noteStats, event.id, hideUntrustedInteractions])
|
||||
const canRepost = !hasReposted && !reposting
|
||||
|
||||
const repost = async () => {
|
||||
|
||||
Reference in New Issue
Block a user