diff --git a/src/components/NoteStats/LikeButton.tsx b/src/components/NoteStats/LikeButton.tsx index 89da53c5..c042a90c 100644 --- a/src/components/NoteStats/LikeButton.tsx +++ b/src/components/NoteStats/LikeButton.tsx @@ -5,7 +5,6 @@ import { DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { createReactionDraftEvent } from '@/lib/draft-event' -import { cn } from '@/lib/utils' import { useNostr } from '@/providers/NostrProvider' import { useNoteStats } from '@/providers/NoteStatsProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' @@ -16,6 +15,7 @@ import { useTranslation } from 'react-i18next' import Emoji from '../Emoji' import EmojiPicker from '../EmojiPicker' import SuggestedEmojis from '../SuggestedEmojis' +import { formatCount } from './utils' export default function LikeButton({ event }: { event: Event }) { const { t } = useTranslation() @@ -25,10 +25,10 @@ export default function LikeButton({ event }: { event: Event }) { const [liking, setLiking] = useState(false) const [isEmojiReactionsOpen, setIsEmojiReactionsOpen] = useState(false) const [isPickerOpen, setIsPickerOpen] = useState(false) - const myLastEmoji = useMemo(() => { + const { myLastEmoji, likeCount } = useMemo(() => { const stats = noteStatsMap.get(event.id) || {} const like = stats.likes?.find((like) => like.pubkey === pubkey) - return like?.emoji + return { myLastEmoji: like?.emoji, likeCount: stats.likes?.length } }, [noteStatsMap, event, pubkey]) const like = async (emoji: string) => { @@ -58,10 +58,7 @@ export default function LikeButton({ event }: { event: Event }) { const trigger = ( ) diff --git a/src/components/NoteStats/index.tsx b/src/components/NoteStats/index.tsx index 5ce9af84..f9017962 100644 --- a/src/components/NoteStats/index.tsx +++ b/src/components/NoteStats/index.tsx @@ -16,7 +16,8 @@ export default function NoteStats({ event, className, classNames, - fetchIfNotExisting = false + fetchIfNotExisting = false, + displayTopZapsAndLikes = false }: { event: Event className?: string @@ -24,6 +25,7 @@ export default function NoteStats({ buttonBar?: string } fetchIfNotExisting?: boolean + displayTopZapsAndLikes?: boolean }) { const { isSmallScreen } = useScreenSize() const { fetchNoteStats } = useNoteStats() @@ -38,8 +40,12 @@ export default function NoteStats({ if (isSmallScreen) { return (
- - + {displayTopZapsAndLikes && ( + <> + + + + )}
- - + {displayTopZapsAndLikes && ( + <> + + + + )}
- + ) : (
{event.kind === kinds.ShortTextNote ? (