zaps can be anon
This commit is contained in:
parent
e7430edb06
commit
b31b10f686
@ -1,4 +1,5 @@
|
|||||||
import "./Zap.css";
|
import "./Zap.css";
|
||||||
|
import { useMemo } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { decode as invoiceDecode } from "light-bolt11-decoder";
|
import { decode as invoiceDecode } from "light-bolt11-decoder";
|
||||||
@ -79,7 +80,7 @@ const Zap = ({ zap, showZapped = true }: { zap: ParsedZap, showZapped?: boolean
|
|||||||
return valid ? (
|
return valid ? (
|
||||||
<div className="zap note card">
|
<div className="zap note card">
|
||||||
<div className="header">
|
<div className="header">
|
||||||
{zapper && <ProfileImage pubkey={zapper} />}
|
{zapper ? <ProfileImage pubkey={zapper} /> : <div>Anon </div>}
|
||||||
{p !== pubKey && showZapped && <ProfileImage pubkey={p} />}
|
{p !== pubKey && showZapped && <ProfileImage pubkey={p} />}
|
||||||
<div className="amount">
|
<div className="amount">
|
||||||
<span className="amount-number">{formatShort(amount)}</span> sats
|
<span className="amount-number">{formatShort(amount)}</span> sats
|
||||||
@ -87,7 +88,7 @@ const Zap = ({ zap, showZapped = true }: { zap: ParsedZap, showZapped?: boolean
|
|||||||
</div>
|
</div>
|
||||||
<div className="body">
|
<div className="body">
|
||||||
<Text
|
<Text
|
||||||
creator={zapper!}
|
creator={zapper || ""}
|
||||||
content={content}
|
content={content}
|
||||||
tags={[]}
|
tags={[]}
|
||||||
users={new Map()}
|
users={new Map()}
|
||||||
@ -100,19 +101,27 @@ const Zap = ({ zap, showZapped = true }: { zap: ParsedZap, showZapped?: boolean
|
|||||||
interface ZapsSummaryProps { zaps: ParsedZap[] }
|
interface ZapsSummaryProps { zaps: ParsedZap[] }
|
||||||
|
|
||||||
export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
|
export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
|
||||||
const topZap = zaps.length > 0 && zaps.reduce((acc, z) => {
|
const sortedZaps = useMemo(() => {
|
||||||
return z.amount > acc.amount ? z : acc
|
const pub = [...zaps.filter(z => z.zapper)]
|
||||||
})
|
const priv = [...zaps.filter(z => !z.zapper)]
|
||||||
const restZaps = zaps.filter(z => topZap && z.id !== topZap.id)
|
pub.sort((a, b) => b.amount - a.amount)
|
||||||
|
return pub.concat(priv)
|
||||||
|
}, [zaps])
|
||||||
|
|
||||||
|
if (zaps.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const [topZap, ...restZaps] = sortedZaps
|
||||||
const restZapsTotal = restZaps.reduce((acc, z) => acc + z.amount, 0)
|
const restZapsTotal = restZaps.reduce((acc, z) => acc + z.amount, 0)
|
||||||
const { zapper, amount, content, valid } = topZap || {}
|
const { zapper, amount, content, valid } = topZap
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="zaps-summary">
|
<div className="zaps-summary">
|
||||||
{amount && valid && zapper && (
|
{amount && (
|
||||||
<div className={`top-zap`}>
|
<div className={`top-zap`}>
|
||||||
<div className="summary">
|
<div className="summary">
|
||||||
<ProfileImage pubkey={zapper} />
|
{zapper ? <ProfileImage pubkey={zapper} /> : <div>Anon </div>}
|
||||||
<div className="amount">
|
<div className="amount">
|
||||||
zapped <span className="amount-number">{formatShort(amount)}</span> sats
|
zapped <span className="amount-number">{formatShort(amount)}</span> sats
|
||||||
</div>
|
</div>
|
||||||
@ -120,7 +129,7 @@ export const ZapsSummary = ({ zaps }: ZapsSummaryProps) => {
|
|||||||
<div className="body">
|
<div className="body">
|
||||||
{content && (
|
{content && (
|
||||||
<Text
|
<Text
|
||||||
creator={zapper}
|
creator={zapper || ""}
|
||||||
content={content}
|
content={content}
|
||||||
tags={[]}
|
tags={[]}
|
||||||
users={new Map()}
|
users={new Map()}
|
||||||
|
Loading…
Reference in New Issue
Block a user