This commit is contained in:
2023-09-12 15:02:16 +01:00
parent f42096fa64
commit 9e2453444d
74 changed files with 776 additions and 728 deletions

View File

@ -26,7 +26,7 @@ export default function CashuNuts({ token }: { token: string }) {
e.stopPropagation();
const lnurl = profile?.lud16 ?? "";
const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent(
lnurl
lnurl,
)}&autopay=yes`;
window.open(url, "_blank");
}

View File

@ -34,7 +34,7 @@ export default function FollowButton(props: FollowButtonProps) {
if (publisher) {
const ev = await publisher.contactList(
follows.item.filter(a => a !== pubkey),
relays.item
relays.item,
);
System.BroadcastEvent(ev);
}

View File

@ -261,9 +261,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
/>
 @ 
<select value={domain} onChange={onDomainChange}>
{serviceConfig?.domains.map(a => (
<option key={a.name}>{a.name}</option>
))}
{serviceConfig?.domains.map(a => <option key={a.name}>{a.name}</option>)}
</select>
</div>
)}

View File

@ -135,7 +135,7 @@ export function NoteInner(props: NoteProps) {
{
[Reaction.Positive]: [] as TaggedNostrEvent[],
[Reaction.Negative]: [] as TaggedNostrEvent[],
}
},
);
return {
[Reaction.Positive]: dedupeByPubkey(result[Reaction.Positive]),
@ -150,7 +150,7 @@ export function NoteInner(props: NoteProps) {
...getReactions(related, ev.id, EventKind.TextNote).filter(e => e.tags.some(tagFilterOfTextRepost(e, ev.id))),
...getReactions(related, ev.id, EventKind.Repost),
]),
[related, ev]
[related, ev],
);
const zaps = useMemo(() => {
const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt)
@ -241,7 +241,7 @@ export function NoteInner(props: NoteProps) {
function goToEvent(
e: React.MouseEvent,
eTarget: TaggedNostrEvent,
isTargetAllowed: boolean = e.target === e.currentTarget
isTargetAllowed: boolean = e.target === e.currentTarget,
) {
if (!isTargetAllowed || opt?.canClick === false) {
return;

View File

@ -2,7 +2,8 @@
border: 1px solid transparent;
border-radius: 12px;
box-shadow: 0px 0px 6px 1px rgba(182, 108, 156, 0.3);
background: linear-gradient(var(--gray-superdark), var(--gray-superdark)) padding-box,
background:
linear-gradient(var(--gray-superdark), var(--gray-superdark)) padding-box,
linear-gradient(90deg, #ef9644, #fd7c49, #ff5e58, #ff3b70, #ff088e, #eb00b1, #c31ed5, #7b41f6) border-box;
}

View File

@ -76,8 +76,8 @@ export function NoteCreator() {
setError(
formatMessage({
defaultMessage: "Invalid LNURL",
})
)
}),
),
);
return;
}
@ -256,9 +256,9 @@ export function NoteCreator() {
? false
: // otherwise return selectedCustomRelays with target relay added / removed
a.filter(el =>
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el)
)
)
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el),
),
),
)
}
/>

View File

@ -71,7 +71,7 @@ export default function NoteFooter(props: NoteFooterProps) {
},
{
captureEvent: true,
}
},
);
function hasReacted(emoji: string) {

View File

@ -46,7 +46,7 @@ export default function NoteReaction(props: NoteReactionProps) {
* Some clients embed the reposted note in the content
*/
function extractRoot() {
if(!inView) return null;
if (!inView) return null;
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
try {
const r: NostrEvent = JSON.parse(ev.content);
@ -66,7 +66,7 @@ export default function NoteReaction(props: NoteReactionProps) {
const root = useMemo(() => extractRoot(), [ev, props.root, inView]);
if (!inView) {
return (<div className="card reaction" ref={ref}></div>)
return <div className="card reaction" ref={ref}></div>;
}
const isOpMuted = root && isMuted(root.pubkey);
const shouldNotBeRendered = isOpMuted || root?.kind !== EventKind.TextNote;

View File

@ -47,15 +47,15 @@ export default function Poll(props: PollProps) {
},
{
amount,
}
)
},
),
);
}
setVoting(opt);
const r = Object.keys(relays.item);
const zap = await publisher.zap(amount * 1000, props.ev.pubkey, r, props.ev.id, undefined, eb =>
eb.tag(["poll_option", opt.toString()])
eb.tag(["poll_option", opt.toString()]),
);
const lnurl = props.ev.tags.find(a => a[0] === "zap")?.[1] || pollerProfile?.lud16 || pollerProfile?.lud06;
@ -68,7 +68,7 @@ export default function Poll(props: PollProps) {
throw new Error(
formatMessage({
defaultMessage: "Can't vote because LNURL service does not support zaps",
})
}),
);
}
@ -85,7 +85,7 @@ export default function Poll(props: PollProps) {
setError(
formatMessage({
defaultMessage: "Failed to send vote",
})
}),
);
}
} finally {

View File

@ -34,7 +34,7 @@ export default function PubkeyList({ ev, className }: { ev: NostrEvent; classNam
pk,
Object.keys(login.relays.item),
undefined,
`Zap from ${hexToBech32("note", ev.id)}`
`Zap from ${hexToBech32("note", ev.id)}`,
);
const invoice = await svc.getInvoice(amtSend, undefined, zap);
if (invoice.pr) {

View File

@ -55,9 +55,9 @@ export function ReBroadcaster() {
? false
: // otherwise return selectedCustomRelays with target relay added / removed
a.filter(el =>
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el)
)
)
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el),
),
),
)
}
/>

View File

@ -60,7 +60,7 @@ const Reactions = ({ show, setShow, positive, negative, reposts, zaps }: Reactio
value: 3,
},
]
: []
: [],
);
const [tab, setTab] = useState(tabs[0]);

View File

@ -22,7 +22,7 @@ export default function Relay(props: RelayProps) {
const navigate = useNavigate();
const login = useLogin();
const relaySettings = unwrap(
login.relays.item[props.addr] ?? System.Sockets.find(a => a.address === props.addr)?.settings ?? {}
login.relays.item[props.addr] ?? System.Sockets.find(a => a.address === props.addr)?.settings ?? {},
);
const state = useRelayState(props.addr);
const name = useMemo(() => getRelayName(props.addr), [props.addr]);
@ -34,7 +34,7 @@ export default function Relay(props: RelayProps) {
...login.relays.item,
[props.addr]: o,
},
unixNowMs()
unixNowMs(),
);
}

View File

@ -285,7 +285,7 @@ export default function SendSats(props: SendSatsProps) {
{makeTab(ZapType.AnonZap, <FormattedMessage defaultMessage="Anon" description="Anonymous Zap" />)}
{makeTab(
ZapType.NonZap,
<FormattedMessage defaultMessage="Non-Zap" description="Non-Zap, Regular LN payment" />
<FormattedMessage defaultMessage="Non-Zap" description="Non-Zap, Regular LN payment" />,
)}
</div>
</>

View File

@ -243,7 +243,7 @@ export default function Thread() {
if (t?.root?.key === "a" && t?.root?.value) {
const parsed = t.root.value.split(":");
replyTo = thread.data?.find(
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2]
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2],
)?.id;
}
if (replyTo) {
@ -264,7 +264,7 @@ export default function Thread() {
thread.data?.find(
ne =>
ne.id === currentId ||
(link.type === NostrPrefix.Address && findTag(ne, "d") === currentId && ne.pubkey === link.author)
(link.type === NostrPrefix.Address && findTag(ne, "d") === currentId && ne.pubkey === link.author),
) ?? (location.state && "sig" in location.state ? (location.state as TaggedNostrEvent) : undefined);
if (currentNote) {
const currentThread = EventExt.extractThread(currentNote);
@ -280,7 +280,7 @@ export default function Thread() {
if (replyTo.key === "a" && replyTo.value) {
const parsed = replyTo.value.split(":");
return thread.data?.find(
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2]
a => a.kind === Number(parsed[0]) && a.pubkey === parsed[1] && findTag(a, "d") === parsed[2],
);
}
if (replyTo.value) {
@ -348,7 +348,7 @@ export default function Thread() {
notes={replies}
related={getAllReactions(
thread.data,
replies.map(a => a.id)
replies.map(a => a.id),
)}
chains={chains}
onNavigate={navigateThread}

View File

@ -47,7 +47,7 @@ const Timeline = (props: TimelineProps) => {
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
.filter(a => props.ignoreModeration || !isMuted(a.pubkey));
},
[props.postsOnly, muted, props.ignoreModeration]
[props.postsOnly, muted, props.ignoreModeration],
);
const mainFeed = useMemo(() => {
@ -60,7 +60,7 @@ const Timeline = (props: TimelineProps) => {
(id: u256) => {
return (feed.related ?? []).filter(a => findTag(a, "e") === id);
},
[feed.related]
[feed.related],
);
const liveStreams = useMemo(() => {
return (feed.main ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live");

View File

@ -28,11 +28,11 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
const [latest, setLatest] = useState(unixNow());
const feed = useSyncExternalStore(
cb => FollowsFeed.hook(cb, "*"),
() => FollowsFeed.snapshot()
() => FollowsFeed.snapshot(),
);
const reactions = useReactions(
"follows-feed-reactions",
feed.map(a => a.id)
feed.map(a => a.id),
);
const system = useContext(SnortContext);
const login = useLogin();
@ -48,7 +48,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
.filter(a => !isMuted(a.pubkey) && login.follows.item.includes(a.pubkey));
},
[props.postsOnly, muted, login.follows.timestamp]
[props.postsOnly, muted, login.follows.timestamp],
);
const mainFeed = useMemo(() => {
@ -63,7 +63,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
(id: u256) => {
return (reactions?.data ?? []).filter(a => findTag(a, "e") === id);
},
[reactions]
[reactions],
);
const liveStreams = useMemo(() => {

View File

@ -17,7 +17,7 @@ export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) {
ev.tags.find(a => a[0] === "d")?.[1] ?? "",
undefined,
ev.kind,
ev.pubkey
ev.pubkey,
);
return (
<>