import "./Zap.css"; import { useMemo } from "react"; import { ParsedZap } from "@snort/system"; import { FormattedMessage, useIntl } from "react-intl"; import { unwrap } from "SnortUtils"; import { formatShort } from "Number"; import Text from "Element/Text"; import ProfileImage from "Element/ProfileImage"; import useLogin from "Hooks/useLogin"; import messages from "./messages"; const Zap = ({ zap, showZapped = true }: { zap: ParsedZap; showZapped?: boolean }) => { const { amount, content, sender, valid, receiver } = zap; const pubKey = useLogin().publicKey; return valid && sender ? (
{receiver !== pubKey && showZapped && }
{(content?.length ?? 0) > 0 && sender && (
)}
) : null; }; interface ZapsSummaryProps { zaps: ParsedZap[]; } export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => { const { formatMessage } = useIntl(); const sortedZaps = useMemo(() => { const pub = [...zaps.filter(z => z.sender && z.valid)]; const priv = [...zaps.filter(z => !z.sender && z.valid)]; pub.sort((a, b) => b.amount - a.amount); return pub.concat(priv); }, [zaps]); if (zaps.length === 0) { return null; } const [topZap, ...restZaps] = sortedZaps; const { sender, amount, anonZap } = topZap; return (
{amount && (
{sender && ( )} {restZaps.length > 0 ? ( ) : ( )}{" "}
)}
); }; export default Zap;