From 0c10138a80cb544acceba6e0892ccbc56d3253b1 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 1 Nov 2025 07:33:23 +0100 Subject: [PATCH] emojis become likes, in quiet mode --- src/components/Note/Zap.tsx | 23 +++++++++++++++++++++-- src/components/NoteStats/LikeButton.tsx | 4 +++- src/components/NoteStats/Likes.tsx | 21 ++++++++++++++++----- src/components/ReactionList/index.tsx | 4 +++- src/components/ZapList/index.tsx | 7 +++++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/components/Note/Zap.tsx b/src/components/Note/Zap.tsx index 1e4ce0d..1b30f61 100644 --- a/src/components/Note/Zap.tsx +++ b/src/components/Note/Zap.tsx @@ -1,5 +1,6 @@ import { useFetchEvent } from '@/hooks' import { getZapInfoFromEvent } from '@/lib/event-metadata' +import { shouldHideInteractions } from '@/lib/event-filtering' import { formatAmount } from '@/lib/lightning' import { toNote, toProfile } from '@/lib/link' import { cn } from '@/lib/utils' @@ -12,11 +13,29 @@ import Username from '../Username' import UserAvatar from '../UserAvatar' export default function Zap({ event, className }: { event: Event; className?: string }) { + // In quiet mode, we need to check the target event (if this is a zap receipt for an event) + // For profile zaps, we can't check quiet mode since we don't have an event + const zapInfo = useMemo(() => getZapInfoFromEvent(event), [event]) + const { event: targetEvent } = useFetchEvent(zapInfo?.eventId) + + // Check if the target event (if any) is in quiet mode + const inQuietMode = targetEvent ? shouldHideInteractions(targetEvent) : false + + // Hide zap receipts in quiet mode as they contain emojis and text + if (inQuietMode) { + return null + } const { t } = useTranslation() const { navigateToNote } = useSmartNoteNavigation() const { push } = useSecondaryPage() - const zapInfo = useMemo(() => getZapInfoFromEvent(event), [event]) - const { event: targetEvent } = useFetchEvent(zapInfo?.eventId) + + if (!zapInfo || !zapInfo.senderPubkey || !zapInfo.amount) { + return ( +
+ [{t('Invalid zap receipt')}] +
+ ) + } // Determine if this is an event zap or profile zap const isEventZap = targetEvent || zapInfo?.eventId diff --git a/src/components/NoteStats/LikeButton.tsx b/src/components/NoteStats/LikeButton.tsx index cd3f16e..ed1743e 100644 --- a/src/components/NoteStats/LikeButton.tsx +++ b/src/components/NoteStats/LikeButton.tsx @@ -6,6 +6,7 @@ import { } from '@/components/ui/dropdown-menu' import { ExtendedKind } from '@/constants' import { useNoteStatsById } from '@/hooks/useNoteStatsById' +import { shouldHideInteractions } from '@/lib/event-filtering' import { createDeletionRequestDraftEvent, createReactionDraftEvent } from '@/lib/draft-event' import { getRootEventHexId } from '@/lib/event' import { useNostr } from '@/providers/NostrProvider' @@ -34,6 +35,7 @@ export default function LikeButton({ event, hideCount = false }: { event: Event; const [isPickerOpen, setIsPickerOpen] = useState(false) const noteStats = useNoteStatsById(event.id) const isDiscussion = event.kind === ExtendedKind.DISCUSSION + const inQuietMode = shouldHideInteractions(event) // Check if this is a reply to a discussion event const [isReplyToDiscussion, setIsReplyToDiscussion] = useState(false) @@ -143,7 +145,7 @@ export default function LikeButton({ event, hideCount = false }: { event: Event; ) : myLastEmoji ? ( <> - + {!hideCount && !!likeCount &&
{formatCount(likeCount)}
} ) : ( diff --git a/src/components/NoteStats/Likes.tsx b/src/components/NoteStats/Likes.tsx index 5f1eda2..908af71 100644 --- a/src/components/NoteStats/Likes.tsx +++ b/src/components/NoteStats/Likes.tsx @@ -1,5 +1,6 @@ import { ScrollArea, ScrollBar } from '@/components/ui/scroll-area' import { useNoteStatsById } from '@/hooks/useNoteStatsById' +import { shouldHideInteractions } from '@/lib/event-filtering' import { createReactionDraftEvent } from '@/lib/draft-event' import { cn } from '@/lib/utils' import { useNostr } from '@/providers/NostrProvider' @@ -11,6 +12,7 @@ import { useMemo, useRef, useState } from 'react' import Emoji from '../Emoji' export default function Likes({ event }: { event: Event }) { + const inQuietMode = shouldHideInteractions(event) const { pubkey, checkLogin, publish } = useNostr() const noteStats = useNoteStatsById(event.id) const [liking, setLiking] = useState(null) @@ -24,14 +26,23 @@ export default function Likes({ event }: { event: Event }) { const stats = new Map }>() _likes.forEach((item) => { - const key = typeof item.emoji === 'string' ? item.emoji : item.emoji.url - if (!stats.has(key)) { - stats.set(key, { key, pubkeys: new Set(), emoji: item.emoji }) + // In quiet mode, normalize all emojis to "+" to prevent trolling with funny emojis + if (inQuietMode) { + const key = '+' + if (!stats.has(key)) { + stats.set(key, { key, pubkeys: new Set(), emoji: '+' }) + } + stats.get(key)?.pubkeys.add(item.pubkey) + } else { + const key = typeof item.emoji === 'string' ? item.emoji : item.emoji.url + if (!stats.has(key)) { + stats.set(key, { key, pubkeys: new Set(), emoji: item.emoji }) + } + stats.get(key)?.pubkeys.add(item.pubkey) } - stats.get(key)?.pubkeys.add(item.pubkey) }) return Array.from(stats.values()).sort((a, b) => b.pubkeys.size - a.pubkeys.size) - }, [noteStats, event]) + }, [noteStats, event, inQuietMode]) if (!likes.length) return null diff --git a/src/components/ReactionList/index.tsx b/src/components/ReactionList/index.tsx index 2c0374f..f3f848d 100644 --- a/src/components/ReactionList/index.tsx +++ b/src/components/ReactionList/index.tsx @@ -1,6 +1,7 @@ import { useSecondaryPage } from '@/PageManager' import { ExtendedKind } from '@/constants' import { useNoteStatsById } from '@/hooks/useNoteStatsById' +import { shouldHideInteractions } from '@/lib/event-filtering' import { toProfile } from '@/lib/link' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { useUserTrust } from '@/providers/UserTrustProvider' @@ -16,6 +17,7 @@ import Username from '../Username' const SHOW_COUNT = 20 export default function ReactionList({ event }: { event: Event }) { + const inQuietMode = shouldHideInteractions(event) const { t } = useTranslation() const { push } = useSecondaryPage() const { isSmallScreen } = useScreenSize() @@ -59,7 +61,7 @@ export default function ReactionList({ event }: { event: Event }) { >