From 6e956855bbf26c9129d0736d80b6e295fa1c21ef Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Mon, 3 Jul 2023 07:36:41 -0500 Subject: [PATCH] fix build --- src/components/note/note-zap-button.tsx | 17 ++++++- src/components/note/note-zaps-modal.tsx | 47 +++++++++---------- src/components/zap-modal.tsx | 14 ++++-- .../stream/stream-chat/chat-message.tsx | 2 +- src/views/user/zaps.tsx | 10 +--- 5 files changed, 48 insertions(+), 42 deletions(-) diff --git a/src/components/note/note-zap-button.tsx b/src/components/note/note-zap-button.tsx index 3752d4c99..42b32e0bb 100644 --- a/src/components/note/note-zap-button.tsx +++ b/src/components/note/note-zap-button.tsx @@ -11,7 +11,12 @@ import ZapModal from "../zap-modal"; import { useInvoiceModalContext } from "../../providers/invoice-modal"; import useUserLNURLMetadata from "../../hooks/use-user-lnurl-metadata"; -export default function NoteZapButton({ note, ...props }: { note: NostrEvent } & Omit) { +export default function NoteZapButton({ + note, + allowComment, + showEventPreview, + ...props +}: { note: NostrEvent; allowComment?: boolean; showEventPreview?: boolean } & Omit) { const account = useCurrentAccount(); const { metadata } = useUserLNURLMetadata(note.pubkey); const { requestPay } = useInvoiceModalContext(); @@ -40,7 +45,15 @@ export default function NoteZapButton({ note, ...props }: { note: NostrEvent } & {readablizeSats(totalZaps(zaps) / 1000)} {isOpen && ( - + )} ); diff --git a/src/components/note/note-zaps-modal.tsx b/src/components/note/note-zaps-modal.tsx index 679300824..2b93f8f3d 100644 --- a/src/components/note/note-zaps-modal.tsx +++ b/src/components/note/note-zaps-modal.tsx @@ -17,7 +17,7 @@ import { UserAvatarLink } from "../user-avatar-link"; import { UserLink } from "../user-link"; import dayjs from "dayjs"; import { DislikeIcon, LightningIcon, LikeIcon } from "../icons"; -import { parseZapEvent } from "../../helpers/zaps"; +import { ParsedZap, parseZapEvent } from "../../helpers/zaps"; import { readablizeSats } from "../../helpers/bolt11"; import useEventReactions from "../../hooks/use-event-reactions"; import useEventZaps from "../../hooks/use-event-zaps"; @@ -47,33 +47,25 @@ const ReactionEvent = React.memo(({ event }: { event: NostrEvent }) => ( )); -const ZapEvent = React.memo(({ event }: { event: NostrEvent }) => { +const ZapEvent = React.memo(({ zap }: { zap: ParsedZap }) => { const isMobile = useIsMobile(); - try { - const { payment, request } = parseZapEvent(event); - if (!payment.amount) return null; + if (!zap.payment.amount) return null; - return ( - - - - - - - - {readablizeSats(payment.amount / 1000)} - - {/* - {dayjs.unix(event.created_at).fromNow()} - */} - - {request.content} - - ); - } catch (e) { - return Invalid Zap; - } + return ( + + + + + + + + {readablizeSats(zap.payment.amount / 1000)} + + + {zap.request.content} + + ); }); function sortEvents(a: NostrEvent, b: NostrEvent) { @@ -111,7 +103,10 @@ export default function NoteReactionsModal({ {selected === "reactions" && reactions.sort(sortEvents).map((event) => )} - {selected === "zaps" && zaps.sort(sortEvents).map((event) => )} + {selected === "zaps" && + zaps + .sort((a, b) => b.request.created_at - a.request.created_at) + .map((zap) => )} diff --git a/src/components/zap-modal.tsx b/src/components/zap-modal.tsx index cadd0cee8..1b1630dae 100644 --- a/src/components/zap-modal.tsx +++ b/src/components/zap-modal.tsx @@ -48,6 +48,8 @@ export type ZapModalProps = Omit & { initialComment?: string; initialAmount?: number; onInvoice: (invoice: string) => void; + allowComment?: boolean; + showEventPreview?: boolean; }; export default function ZapModal({ @@ -58,6 +60,8 @@ export default function ZapModal({ initialComment, initialAmount, onInvoice, + allowComment = true, + showEventPreview = true, ...props }: ZapModalProps) { const toast = useToast(); @@ -146,15 +150,15 @@ export default function ZapModal({
- + - {tipAddress} + {tipAddress} - {stream && ( + {showEventPreview && stream && ( Stream: {stream.title} @@ -162,9 +166,9 @@ export default function ZapModal({ {stream.image && } )} - {event && } + {showEventPreview && event && } - {(canZap || lnurlMetadata?.commentAllowed) && ( + {allowComment && (canZap || lnurlMetadata?.commentAllowed) && ( - + diff --git a/src/views/user/zaps.tsx b/src/views/user/zaps.tsx index 2940a701f..8dd1d9c1d 100644 --- a/src/views/user/zaps.tsx +++ b/src/views/user/zaps.tsx @@ -1,4 +1,4 @@ -import { Box, Button, Flex, Select, Text, useDisclosure } from "@chakra-ui/react"; +import { Box, Flex, Select, Text } from "@chakra-ui/react"; import dayjs from "dayjs"; import { useCallback, useMemo, useRef, useState } from "react"; import { useOutletContext } from "react-router-dom"; @@ -20,7 +20,6 @@ import IntersectionObserverProvider, { useRegisterIntersectionEntity } from "../ import { useTimelineCurserIntersectionCallback } from "../../hooks/use-timeline-cursor-intersection-callback"; const Zap = ({ zapEvent }: { zapEvent: NostrEvent }) => { - const { isOpen, onToggle } = useDisclosure(); const ref = useRef(null); useRegisterIntersectionEntity(ref, zapEvent.id); @@ -51,14 +50,9 @@ const Zap = ({ zapEvent }: { zapEvent: NostrEvent }) => { {readablizeSats(payment.amount / 1000)} sats )} - {request.content && ( - - )} {dayjs.unix(request.created_at).fromNow()} - {request.content && isOpen && {request.content}} + {request.content && {request.content}} ); } catch (e) {