diff --git a/src/components/ReplyNote/index.tsx b/src/components/ReplyNote/index.tsx index 7851575..1c3c466 100644 --- a/src/components/ReplyNote/index.tsx +++ b/src/components/ReplyNote/index.tsx @@ -1,12 +1,14 @@ import { useSecondaryPage } from '@/PageManager' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' -import { isMentioningMutedUsers } from '@/lib/event' +import { getEventKey, isMentioningMutedUsers } from '@/lib/event' import { toNote } from '@/lib/link' import { cn } from '@/lib/utils' import { useContentPolicy } from '@/providers/ContentPolicyProvider' import { useMuteList } from '@/providers/MuteListProvider' +import { useReply } from '@/providers/ReplyProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' +import { useUserTrust } from '@/providers/UserTrustProvider' import { Event } from 'nostr-tools' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -40,7 +42,9 @@ export default function ReplyNote({ const { isSmallScreen } = useScreenSize() const { push } = useSecondaryPage() const { mutePubkeySet } = useMuteList() + const { hideUntrustedInteractions, isUserTrusted } = useUserTrust() const { hideContentMentioningMutedUsers } = useContentPolicy() + const { repliesMap } = useReply() const [showMuted, setShowMuted] = useState(false) const show = useMemo(() => { if (showMuted) { @@ -54,16 +58,37 @@ export default function ReplyNote({ } return true }, [showMuted, mutePubkeySet, event, hideContentMentioningMutedUsers]) + const hasReplies = useMemo(() => { + const key = getEventKey(event) + const replies = repliesMap.get(key)?.events + if (!replies || replies.length === 0) { + return false + } + + for (const reply of replies) { + if (hideUntrustedInteractions && !isUserTrusted(reply.pubkey)) { + continue + } + if (mutePubkeySet.has(reply.pubkey)) { + continue + } + if (hideContentMentioningMutedUsers && isMentioningMutedUsers(reply, mutePubkeySet)) { + continue + } + return true + } + }, [event, repliesMap]) return (
push(toNote(event))} > + {hasReplies &&
}
diff --git a/src/components/ReplyNoteList/SubReplies.tsx b/src/components/ReplyNoteList/SubReplies.tsx index f154e7d..e752740 100644 --- a/src/components/ReplyNoteList/SubReplies.tsx +++ b/src/components/ReplyNoteList/SubReplies.tsx @@ -81,7 +81,7 @@ export default function SubReplies({ parentKey }: { parentKey: string }) { }, 1500) }, []) - if (replies.length === 0) return
+ if (replies.length === 0) return null return (
@@ -91,11 +91,16 @@ export default function SubReplies({ parentKey }: { parentKey: string }) { e.stopPropagation() setIsExpanded(!isExpanded) }} - className={cn( - 'w-full flex items-center gap-1.5 pl-14 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors clickable', - !isExpanded && 'border-b' - )} + className="relative w-full flex items-center gap-1.5 pl-14 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors clickable" > +
{isExpanded ? ( <> @@ -125,14 +130,14 @@ export default function SubReplies({ parentKey }: { parentKey: string }) {
(replyRefs.current[currentReplyKey] = el)} key={currentReplyKey} - className="scroll-mt-12 flex" + className="scroll-mt-12 flex relative" > -
+
+ {index < replies.length - 1 && ( +
+ )} { diff --git a/src/components/ReplyNoteList/index.tsx b/src/components/ReplyNoteList/index.tsx index 90386d8..9f3c937 100644 --- a/src/components/ReplyNoteList/index.tsx +++ b/src/components/ReplyNoteList/index.tsx @@ -272,15 +272,9 @@ export default function ReplyNoteList({
)}
- {replies.slice(0, showCount).map((reply) => { - const key = getEventKey(reply) - return ( -
- - -
- ) - })} + {replies.slice(0, showCount).map((reply) => ( + + ))}
{!loading && (
@@ -292,3 +286,14 @@ export default function ReplyNoteList({
) } + +function Item({ reply }: { reply: NEvent }) { + const key = useMemo(() => getEventKey(reply), [reply]) + + return ( +
+ + +
+ ) +}