Prettier
This commit is contained in:
parent
f42096fa64
commit
9e2453444d
@ -1,10 +1,10 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Snort Benchmarks</title>
|
<title>Snort Benchmarks</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Check console
|
Check console
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
@ -38,7 +38,7 @@ export class GiftWrapCache extends RefreshFeedCache<UnwrappedGift> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug(e, v);
|
console.debug(e, v);
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.filter(a => a !== undefined)
|
.filter(a => a !== undefined)
|
||||||
|
@ -26,7 +26,7 @@ export default function CashuNuts({ token }: { token: string }) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const lnurl = profile?.lud16 ?? "";
|
const lnurl = profile?.lud16 ?? "";
|
||||||
const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent(
|
const url = `https://redeem.cashu.me?token=${encodeURIComponent(token)}&lightning=${encodeURIComponent(
|
||||||
lnurl
|
lnurl,
|
||||||
)}&autopay=yes`;
|
)}&autopay=yes`;
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export default function FollowButton(props: FollowButtonProps) {
|
|||||||
if (publisher) {
|
if (publisher) {
|
||||||
const ev = await publisher.contactList(
|
const ev = await publisher.contactList(
|
||||||
follows.item.filter(a => a !== pubkey),
|
follows.item.filter(a => a !== pubkey),
|
||||||
relays.item
|
relays.item,
|
||||||
);
|
);
|
||||||
System.BroadcastEvent(ev);
|
System.BroadcastEvent(ev);
|
||||||
}
|
}
|
||||||
|
@ -261,9 +261,7 @@ export default function Nip5Service(props: Nip05ServiceProps) {
|
|||||||
/>
|
/>
|
||||||
@
|
@
|
||||||
<select value={domain} onChange={onDomainChange}>
|
<select value={domain} onChange={onDomainChange}>
|
||||||
{serviceConfig?.domains.map(a => (
|
{serviceConfig?.domains.map(a => <option key={a.name}>{a.name}</option>)}
|
||||||
<option key={a.name}>{a.name}</option>
|
|
||||||
))}
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -135,7 +135,7 @@ export function NoteInner(props: NoteProps) {
|
|||||||
{
|
{
|
||||||
[Reaction.Positive]: [] as TaggedNostrEvent[],
|
[Reaction.Positive]: [] as TaggedNostrEvent[],
|
||||||
[Reaction.Negative]: [] as TaggedNostrEvent[],
|
[Reaction.Negative]: [] as TaggedNostrEvent[],
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
[Reaction.Positive]: dedupeByPubkey(result[Reaction.Positive]),
|
[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.TextNote).filter(e => e.tags.some(tagFilterOfTextRepost(e, ev.id))),
|
||||||
...getReactions(related, ev.id, EventKind.Repost),
|
...getReactions(related, ev.id, EventKind.Repost),
|
||||||
]),
|
]),
|
||||||
[related, ev]
|
[related, ev],
|
||||||
);
|
);
|
||||||
const zaps = useMemo(() => {
|
const zaps = useMemo(() => {
|
||||||
const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt)
|
const sortedZaps = getReactions(related, ev.id, EventKind.ZapReceipt)
|
||||||
@ -241,7 +241,7 @@ export function NoteInner(props: NoteProps) {
|
|||||||
function goToEvent(
|
function goToEvent(
|
||||||
e: React.MouseEvent,
|
e: React.MouseEvent,
|
||||||
eTarget: TaggedNostrEvent,
|
eTarget: TaggedNostrEvent,
|
||||||
isTargetAllowed: boolean = e.target === e.currentTarget
|
isTargetAllowed: boolean = e.target === e.currentTarget,
|
||||||
) {
|
) {
|
||||||
if (!isTargetAllowed || opt?.canClick === false) {
|
if (!isTargetAllowed || opt?.canClick === false) {
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
box-shadow: 0px 0px 6px 1px rgba(182, 108, 156, 0.3);
|
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;
|
linear-gradient(90deg, #ef9644, #fd7c49, #ff5e58, #ff3b70, #ff088e, #eb00b1, #c31ed5, #7b41f6) border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ export function NoteCreator() {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Invalid LNURL",
|
defaultMessage: "Invalid LNURL",
|
||||||
})
|
}),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -256,9 +256,9 @@ export function NoteCreator() {
|
|||||||
? false
|
? false
|
||||||
: // otherwise return selectedCustomRelays with target relay added / removed
|
: // otherwise return selectedCustomRelays with target relay added / removed
|
||||||
a.filter(el =>
|
a.filter(el =>
|
||||||
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el)
|
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -71,7 +71,7 @@ export default function NoteFooter(props: NoteFooterProps) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
captureEvent: true,
|
captureEvent: true,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
function hasReacted(emoji: string) {
|
function hasReacted(emoji: string) {
|
||||||
|
@ -46,7 +46,7 @@ export default function NoteReaction(props: NoteReactionProps) {
|
|||||||
* Some clients embed the reposted note in the content
|
* Some clients embed the reposted note in the content
|
||||||
*/
|
*/
|
||||||
function extractRoot() {
|
function extractRoot() {
|
||||||
if(!inView) return null;
|
if (!inView) return null;
|
||||||
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
|
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
|
||||||
try {
|
try {
|
||||||
const r: NostrEvent = JSON.parse(ev.content);
|
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]);
|
const root = useMemo(() => extractRoot(), [ev, props.root, inView]);
|
||||||
|
|
||||||
if (!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 isOpMuted = root && isMuted(root.pubkey);
|
||||||
const shouldNotBeRendered = isOpMuted || root?.kind !== EventKind.TextNote;
|
const shouldNotBeRendered = isOpMuted || root?.kind !== EventKind.TextNote;
|
||||||
|
@ -47,15 +47,15 @@ export default function Poll(props: PollProps) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
amount,
|
amount,
|
||||||
}
|
},
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
setVoting(opt);
|
setVoting(opt);
|
||||||
const r = Object.keys(relays.item);
|
const r = Object.keys(relays.item);
|
||||||
const zap = await publisher.zap(amount * 1000, props.ev.pubkey, r, props.ev.id, undefined, eb =>
|
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;
|
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(
|
throw new Error(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Can't vote because LNURL service does not support zaps",
|
defaultMessage: "Can't vote because LNURL service does not support zaps",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ export default function Poll(props: PollProps) {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Failed to send vote",
|
defaultMessage: "Failed to send vote",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -34,7 +34,7 @@ export default function PubkeyList({ ev, className }: { ev: NostrEvent; classNam
|
|||||||
pk,
|
pk,
|
||||||
Object.keys(login.relays.item),
|
Object.keys(login.relays.item),
|
||||||
undefined,
|
undefined,
|
||||||
`Zap from ${hexToBech32("note", ev.id)}`
|
`Zap from ${hexToBech32("note", ev.id)}`,
|
||||||
);
|
);
|
||||||
const invoice = await svc.getInvoice(amtSend, undefined, zap);
|
const invoice = await svc.getInvoice(amtSend, undefined, zap);
|
||||||
if (invoice.pr) {
|
if (invoice.pr) {
|
||||||
|
@ -55,9 +55,9 @@ export function ReBroadcaster() {
|
|||||||
? false
|
? false
|
||||||
: // otherwise return selectedCustomRelays with target relay added / removed
|
: // otherwise return selectedCustomRelays with target relay added / removed
|
||||||
a.filter(el =>
|
a.filter(el =>
|
||||||
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el)
|
el === r ? e.target.checked : !selectedCustomRelays || selectedCustomRelays.includes(el),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -60,7 +60,7 @@ const Reactions = ({ show, setShow, positive, negative, reposts, zaps }: Reactio
|
|||||||
value: 3,
|
value: 3,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: []
|
: [],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [tab, setTab] = useState(tabs[0]);
|
const [tab, setTab] = useState(tabs[0]);
|
||||||
|
@ -22,7 +22,7 @@ export default function Relay(props: RelayProps) {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const relaySettings = unwrap(
|
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 state = useRelayState(props.addr);
|
||||||
const name = useMemo(() => getRelayName(props.addr), [props.addr]);
|
const name = useMemo(() => getRelayName(props.addr), [props.addr]);
|
||||||
@ -34,7 +34,7 @@ export default function Relay(props: RelayProps) {
|
|||||||
...login.relays.item,
|
...login.relays.item,
|
||||||
[props.addr]: o,
|
[props.addr]: o,
|
||||||
},
|
},
|
||||||
unixNowMs()
|
unixNowMs(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ export default function SendSats(props: SendSatsProps) {
|
|||||||
{makeTab(ZapType.AnonZap, <FormattedMessage defaultMessage="Anon" description="Anonymous Zap" />)}
|
{makeTab(ZapType.AnonZap, <FormattedMessage defaultMessage="Anon" description="Anonymous Zap" />)}
|
||||||
{makeTab(
|
{makeTab(
|
||||||
ZapType.NonZap,
|
ZapType.NonZap,
|
||||||
<FormattedMessage defaultMessage="Non-Zap" description="Non-Zap, Regular LN payment" />
|
<FormattedMessage defaultMessage="Non-Zap" description="Non-Zap, Regular LN payment" />,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -243,7 +243,7 @@ export default function Thread() {
|
|||||||
if (t?.root?.key === "a" && t?.root?.value) {
|
if (t?.root?.key === "a" && t?.root?.value) {
|
||||||
const parsed = t.root.value.split(":");
|
const parsed = t.root.value.split(":");
|
||||||
replyTo = thread.data?.find(
|
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;
|
)?.id;
|
||||||
}
|
}
|
||||||
if (replyTo) {
|
if (replyTo) {
|
||||||
@ -264,7 +264,7 @@ export default function Thread() {
|
|||||||
thread.data?.find(
|
thread.data?.find(
|
||||||
ne =>
|
ne =>
|
||||||
ne.id === currentId ||
|
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);
|
) ?? (location.state && "sig" in location.state ? (location.state as TaggedNostrEvent) : undefined);
|
||||||
if (currentNote) {
|
if (currentNote) {
|
||||||
const currentThread = EventExt.extractThread(currentNote);
|
const currentThread = EventExt.extractThread(currentNote);
|
||||||
@ -280,7 +280,7 @@ export default function Thread() {
|
|||||||
if (replyTo.key === "a" && replyTo.value) {
|
if (replyTo.key === "a" && replyTo.value) {
|
||||||
const parsed = replyTo.value.split(":");
|
const parsed = replyTo.value.split(":");
|
||||||
return thread.data?.find(
|
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) {
|
if (replyTo.value) {
|
||||||
@ -348,7 +348,7 @@ export default function Thread() {
|
|||||||
notes={replies}
|
notes={replies}
|
||||||
related={getAllReactions(
|
related={getAllReactions(
|
||||||
thread.data,
|
thread.data,
|
||||||
replies.map(a => a.id)
|
replies.map(a => a.id),
|
||||||
)}
|
)}
|
||||||
chains={chains}
|
chains={chains}
|
||||||
onNavigate={navigateThread}
|
onNavigate={navigateThread}
|
||||||
|
@ -47,7 +47,7 @@ const Timeline = (props: TimelineProps) => {
|
|||||||
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
|
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
|
||||||
.filter(a => props.ignoreModeration || !isMuted(a.pubkey));
|
.filter(a => props.ignoreModeration || !isMuted(a.pubkey));
|
||||||
},
|
},
|
||||||
[props.postsOnly, muted, props.ignoreModeration]
|
[props.postsOnly, muted, props.ignoreModeration],
|
||||||
);
|
);
|
||||||
|
|
||||||
const mainFeed = useMemo(() => {
|
const mainFeed = useMemo(() => {
|
||||||
@ -60,7 +60,7 @@ const Timeline = (props: TimelineProps) => {
|
|||||||
(id: u256) => {
|
(id: u256) => {
|
||||||
return (feed.related ?? []).filter(a => findTag(a, "e") === id);
|
return (feed.related ?? []).filter(a => findTag(a, "e") === id);
|
||||||
},
|
},
|
||||||
[feed.related]
|
[feed.related],
|
||||||
);
|
);
|
||||||
const liveStreams = useMemo(() => {
|
const liveStreams = useMemo(() => {
|
||||||
return (feed.main ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live");
|
return (feed.main ?? []).filter(a => a.kind === EventKind.LiveEvent && findTag(a, "status") === "live");
|
||||||
|
@ -28,11 +28,11 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
|||||||
const [latest, setLatest] = useState(unixNow());
|
const [latest, setLatest] = useState(unixNow());
|
||||||
const feed = useSyncExternalStore(
|
const feed = useSyncExternalStore(
|
||||||
cb => FollowsFeed.hook(cb, "*"),
|
cb => FollowsFeed.hook(cb, "*"),
|
||||||
() => FollowsFeed.snapshot()
|
() => FollowsFeed.snapshot(),
|
||||||
);
|
);
|
||||||
const reactions = useReactions(
|
const reactions = useReactions(
|
||||||
"follows-feed-reactions",
|
"follows-feed-reactions",
|
||||||
feed.map(a => a.id)
|
feed.map(a => a.id),
|
||||||
);
|
);
|
||||||
const system = useContext(SnortContext);
|
const system = useContext(SnortContext);
|
||||||
const login = useLogin();
|
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 => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
|
||||||
.filter(a => !isMuted(a.pubkey) && login.follows.item.includes(a.pubkey));
|
.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(() => {
|
const mainFeed = useMemo(() => {
|
||||||
@ -63,7 +63,7 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
|||||||
(id: u256) => {
|
(id: u256) => {
|
||||||
return (reactions?.data ?? []).filter(a => findTag(a, "e") === id);
|
return (reactions?.data ?? []).filter(a => findTag(a, "e") === id);
|
||||||
},
|
},
|
||||||
[reactions]
|
[reactions],
|
||||||
);
|
);
|
||||||
|
|
||||||
const liveStreams = useMemo(() => {
|
const liveStreams = useMemo(() => {
|
||||||
|
@ -17,7 +17,7 @@ export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) {
|
|||||||
ev.tags.find(a => a[0] === "d")?.[1] ?? "",
|
ev.tags.find(a => a[0] === "d")?.[1] ?? "",
|
||||||
undefined,
|
undefined,
|
||||||
ev.kind,
|
ev.kind,
|
||||||
ev.pubkey
|
ev.pubkey,
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -23,7 +23,7 @@ export default function useProfileBadges(pubkey?: HexKey) {
|
|||||||
if (profileBadges.data) {
|
if (profileBadges.data) {
|
||||||
return chunks(
|
return chunks(
|
||||||
profileBadges.data.tags.filter(t => t[0] === "a" || t[0] === "e"),
|
profileBadges.data.tags.filter(t => t[0] === "a" || t[0] === "e"),
|
||||||
2
|
2,
|
||||||
).reduce((acc, [a, e]) => {
|
).reduce((acc, [a, e]) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
@ -44,7 +44,7 @@ export default function useProfileBadges(pubkey?: HexKey) {
|
|||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{ pubkeys: [], ds: [] } as BadgeAwards
|
{ pubkeys: [], ds: [] } as BadgeAwards,
|
||||||
) as BadgeAwards;
|
) as BadgeAwards;
|
||||||
}, [profile]);
|
}, [profile]);
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ export default function useProfileBadges(pubkey?: HexKey) {
|
|||||||
})
|
})
|
||||||
.filter(
|
.filter(
|
||||||
({ award, badge }) =>
|
({ award, badge }) =>
|
||||||
badge && award.pubkey === badge.pubkey && award.tags.find(t => t[0] === "p" && t[1] === pubkey)
|
badge && award.pubkey === badge.pubkey && award.tags.find(t => t[0] === "p" && t[1] === pubkey),
|
||||||
)
|
)
|
||||||
.map(({ badge }) => unwrap(badge));
|
.map(({ badge }) => unwrap(badge));
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export function useReactions(subId: string, ids: Array<string>, others?: (rb: Re
|
|||||||
.kinds(
|
.kinds(
|
||||||
pref.enableReactions
|
pref.enableReactions
|
||||||
? [EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt]
|
? [EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt]
|
||||||
: [EventKind.ZapReceipt, EventKind.Repost]
|
: [EventKind.ZapReceipt, EventKind.Repost],
|
||||||
)
|
)
|
||||||
.tag("e", ids);
|
.tag("e", ids);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export default function useFollowersFeed(pubkey?: HexKey) {
|
|||||||
|
|
||||||
const followers = useMemo(() => {
|
const followers = useMemo(() => {
|
||||||
const contactLists = followersFeed.data?.filter(
|
const contactLists = followersFeed.data?.filter(
|
||||||
a => a.kind === EventKind.ContactList && a.tags.some(b => b[0] === "p" && b[1] === pubkey)
|
a => a.kind === EventKind.ContactList && a.tags.some(b => b[0] === "p" && b[1] === pubkey),
|
||||||
);
|
);
|
||||||
return [...new Set(contactLists?.map(a => a.pubkey))];
|
return [...new Set(contactLists?.map(a => a.pubkey))];
|
||||||
}, [followersFeed, pubkey]);
|
}, [followersFeed, pubkey]);
|
||||||
|
@ -85,7 +85,7 @@ export default function useLoginFeed() {
|
|||||||
Nip4Chats.onEvent(loginFeed.data);
|
Nip4Chats.onEvent(loginFeed.data);
|
||||||
|
|
||||||
const subs = loginFeed.data.filter(
|
const subs = loginFeed.data.filter(
|
||||||
a => a.kind === EventKind.SnortSubscriptions && a.pubkey === bech32ToHex(SnortPubKey)
|
a => a.kind === EventKind.SnortSubscriptions && a.pubkey === bech32ToHex(SnortPubKey),
|
||||||
);
|
);
|
||||||
Promise.all(
|
Promise.all(
|
||||||
subs.map(async a => {
|
subs.map(async a => {
|
||||||
@ -97,7 +97,7 @@ export default function useLoginFeed() {
|
|||||||
...ex,
|
...ex,
|
||||||
} as SubscriptionEvent;
|
} as SubscriptionEvent;
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
).then(a => addSubscription(login, ...a.filter(a => a !== undefined).map(unwrap)));
|
).then(a => addSubscription(login, ...a.filter(a => a !== undefined).map(unwrap)));
|
||||||
}
|
}
|
||||||
}, [loginFeed, publisher]);
|
}, [loginFeed, publisher]);
|
||||||
@ -106,7 +106,7 @@ export default function useLoginFeed() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loginFeed.data) {
|
if (loginFeed.data) {
|
||||||
const replies = loginFeed.data.filter(
|
const replies = loginFeed.data.filter(
|
||||||
a => a.kind === EventKind.TextNote && !isMuted(a.pubkey) && a.created_at > readNotifications
|
a => a.kind === EventKind.TextNote && !isMuted(a.pubkey) && a.created_at > readNotifications,
|
||||||
);
|
);
|
||||||
replies.forEach(async nx => {
|
replies.forEach(async nx => {
|
||||||
const n = await makeNotification(nx);
|
const n = await makeNotification(nx);
|
||||||
|
@ -35,11 +35,11 @@ export default function useThreadFeed(link: NostrLink) {
|
|||||||
.kinds(
|
.kinds(
|
||||||
pref.enableReactions
|
pref.enableReactions
|
||||||
? [EventKind.Reaction, EventKind.TextNote, EventKind.Repost, EventKind.ZapReceipt]
|
? [EventKind.Reaction, EventKind.TextNote, EventKind.Repost, EventKind.ZapReceipt]
|
||||||
: [EventKind.TextNote, EventKind.ZapReceipt, EventKind.Repost]
|
: [EventKind.TextNote, EventKind.ZapReceipt, EventKind.Repost],
|
||||||
)
|
)
|
||||||
.tag(
|
.tag(
|
||||||
"e",
|
"e",
|
||||||
allEvents.map(a => a.id)
|
allEvents.map(a => a.id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (trackingATags.length > 0) {
|
if (trackingATags.length > 0) {
|
||||||
@ -50,7 +50,7 @@ export default function useThreadFeed(link: NostrLink) {
|
|||||||
.authors(parsed.map(a => a[1]))
|
.authors(parsed.map(a => a[1]))
|
||||||
.tag(
|
.tag(
|
||||||
"d",
|
"d",
|
||||||
parsed.map(a => a[2])
|
parsed.map(a => a[2]),
|
||||||
);
|
);
|
||||||
sub.withFilter().tag("a", trackingATags);
|
sub.withFilter().tag("a", trackingATags);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ export default function useThreadFeed(link: NostrLink) {
|
|||||||
id: b[1],
|
id: b[1],
|
||||||
relay: b[2],
|
relay: b[2],
|
||||||
};
|
};
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
.flat();
|
.flat();
|
||||||
const eTagsMissing = eTags.filter(a => !mainNotes.some(b => b.id === a.id));
|
const eTagsMissing = eTags.filter(a => !mainNotes.some(b => b.id === a.id));
|
||||||
|
@ -43,7 +43,7 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
|
|||||||
.kinds(
|
.kinds(
|
||||||
subject.type === "profile_keyword"
|
subject.type === "profile_keyword"
|
||||||
? [EventKind.SetMetadata]
|
? [EventKind.SetMetadata]
|
||||||
: [EventKind.TextNote, EventKind.Repost, EventKind.Polls]
|
: [EventKind.TextNote, EventKind.Repost, EventKind.Polls],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (subject.relay) {
|
if (subject.relay) {
|
||||||
@ -149,7 +149,7 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
|
|||||||
.map(a => unwrap(a)[1]);
|
.map(a => unwrap(a)[1]);
|
||||||
const repostsByKind1 = main.data
|
const repostsByKind1 = main.data
|
||||||
.filter(
|
.filter(
|
||||||
a => (a.kind === EventKind.Repost || a.kind === EventKind.TextNote) && a.tags.some(tagFilterOfTextRepost(a))
|
a => (a.kind === EventKind.Repost || a.kind === EventKind.TextNote) && a.tags.some(tagFilterOfTextRepost(a)),
|
||||||
)
|
)
|
||||||
.map(a => a.tags.find(tagFilterOfTextRepost(a)))
|
.map(a => a.tags.find(tagFilterOfTextRepost(a)))
|
||||||
.filter(a => a)
|
.filter(a => a)
|
||||||
|
@ -21,7 +21,7 @@ export default function useImgProxy() {
|
|||||||
const result = hmacSha256(
|
const result = hmacSha256(
|
||||||
utils.hexToBytes(unwrap(settings).key),
|
utils.hexToBytes(unwrap(settings).key),
|
||||||
utils.hexToBytes(unwrap(settings).salt),
|
utils.hexToBytes(unwrap(settings).salt),
|
||||||
te.encode(u)
|
te.encode(u),
|
||||||
);
|
);
|
||||||
return urlSafe(base64.encode(result));
|
return urlSafe(base64.encode(result));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export function useInteractionCache(pubkey?: HexKey, event?: u256) {
|
|||||||
const data =
|
const data =
|
||||||
useSyncExternalStore(
|
useSyncExternalStore(
|
||||||
c => InteractionCache.hook(c, id),
|
c => InteractionCache.hook(c, id),
|
||||||
() => InteractionCache.snapshot().find(a => a.id === id)
|
() => InteractionCache.snapshot().find(a => a.id === id),
|
||||||
) || EmptyInteraction;
|
) || EmptyInteraction;
|
||||||
return {
|
return {
|
||||||
data: data,
|
data: data,
|
||||||
|
@ -4,6 +4,6 @@ import { useSyncExternalStore } from "react";
|
|||||||
export default function useLogin() {
|
export default function useLogin() {
|
||||||
return useSyncExternalStore(
|
return useSyncExternalStore(
|
||||||
s => LoginStore.hook(s),
|
s => LoginStore.hook(s),
|
||||||
() => LoginStore.snapshot()
|
() => LoginStore.snapshot(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
|
|||||||
type: LoginSessionType,
|
type: LoginSessionType,
|
||||||
relays?: Record<string, RelaySettings>,
|
relays?: Record<string, RelaySettings>,
|
||||||
remoteSignerRelays?: Array<string>,
|
remoteSignerRelays?: Array<string>,
|
||||||
privateKey?: string
|
privateKey?: string,
|
||||||
) {
|
) {
|
||||||
if (this.#accounts.has(key)) {
|
if (this.#accounts.has(key)) {
|
||||||
throw new Error("Already logged in with this pubkey");
|
throw new Error("Already logged in with this pubkey");
|
||||||
|
@ -97,7 +97,7 @@ export class ServiceProvider {
|
|||||||
path: string,
|
path: string,
|
||||||
method?: "GET" | string,
|
method?: "GET" | string,
|
||||||
body?: unknown,
|
body?: unknown,
|
||||||
headers?: { [key: string]: string }
|
headers?: { [key: string]: string },
|
||||||
): Promise<T | ServiceError> {
|
): Promise<T | ServiceError> {
|
||||||
try {
|
try {
|
||||||
const rsp = await fetch(`${this.url}${path}`, {
|
const rsp = await fetch(`${this.url}${path}`, {
|
||||||
|
@ -54,7 +54,7 @@ export default class SnortServiceProvider extends ServiceProvider {
|
|||||||
path: string,
|
path: string,
|
||||||
method?: "GET" | string,
|
method?: "GET" | string,
|
||||||
body?: unknown,
|
body?: unknown,
|
||||||
headers?: { [key: string]: string }
|
headers?: { [key: string]: string },
|
||||||
): Promise<T | ServiceError> {
|
): Promise<T | ServiceError> {
|
||||||
const auth = await this.#publisher.generic(eb => {
|
const auth = await this.#publisher.generic(eb => {
|
||||||
eb.kind(EventKind.HttpAuthentication);
|
eb.kind(EventKind.HttpAuthentication);
|
||||||
|
@ -25,7 +25,7 @@ const ErrorPage = () => {
|
|||||||
{JSON.stringify(
|
{JSON.stringify(
|
||||||
error instanceof Error ? { name: error.name, message: error.message, stack: error.stack } : error,
|
error instanceof Error ? { name: error.name, message: error.message, stack: error.stack } : error,
|
||||||
undefined,
|
undefined,
|
||||||
" "
|
" ",
|
||||||
)}
|
)}
|
||||||
</pre>
|
</pre>
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ export default function Layout() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const osTheme = window.matchMedia("(prefers-color-scheme: light)");
|
const osTheme = window.matchMedia("(prefers-color-scheme: light)");
|
||||||
setTheme(
|
setTheme(
|
||||||
preferences.theme === "system" && osTheme.matches ? "light" : preferences.theme === "light" ? "light" : "dark"
|
preferences.theme === "system" && osTheme.matches ? "light" : preferences.theme === "light" ? "light" : "dark",
|
||||||
);
|
);
|
||||||
|
|
||||||
osTheme.onchange = e => {
|
osTheme.onchange = e => {
|
||||||
@ -174,7 +174,7 @@ const AccountHeader = () => {
|
|||||||
|
|
||||||
const hasNotifications = useMemo(
|
const hasNotifications = useMemo(
|
||||||
() => latestNotification > readNotifications,
|
() => latestNotification > readNotifications,
|
||||||
[latestNotification, readNotifications]
|
[latestNotification, readNotifications],
|
||||||
);
|
);
|
||||||
const unreadDms = useMemo(() => (publicKey ? 0 : 0), [publicKey]);
|
const unreadDms = useMemo(() => (publicKey ? 0 : 0), [publicKey]);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ const Artwork: Array<ArtworkEntry> = [
|
|||||||
export async function getNip05PubKey(addr: string): Promise<string> {
|
export async function getNip05PubKey(addr: string): Promise<string> {
|
||||||
const [username, domain] = addr.split("@");
|
const [username, domain] = addr.split("@");
|
||||||
const rsp = await fetch(
|
const rsp = await fetch(
|
||||||
`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(username.toLocaleLowerCase())}`
|
`https://${domain}/.well-known/nostr.json?name=${encodeURIComponent(username.toLocaleLowerCase())}`,
|
||||||
);
|
);
|
||||||
if (rsp.ok) {
|
if (rsp.ok) {
|
||||||
const data = await rsp.json();
|
const data = await rsp.json();
|
||||||
@ -103,7 +103,7 @@ export default function LoginPage() {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown login error",
|
defaultMessage: "Unknown login error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -75,7 +75,7 @@ export default function NotificationsPage() {
|
|||||||
|
|
||||||
const notifications = useSyncExternalStore(
|
const notifications = useSyncExternalStore(
|
||||||
c => Notifications.hook(c, "*"),
|
c => Notifications.hook(c, "*"),
|
||||||
() => Notifications.snapshot()
|
() => Notifications.snapshot(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const timeKey = (ev: NostrEvent) => {
|
const timeKey = (ev: NostrEvent) => {
|
||||||
@ -119,7 +119,7 @@ function NotificationGroup({ evs }: { evs: Array<TaggedNostrEvent> }) {
|
|||||||
return zap.anonZap ? "anon" : zap.sender ?? a.pubkey;
|
return zap.anonZap ? "anon" : zap.sender ?? a.pubkey;
|
||||||
}
|
}
|
||||||
return a.pubkey;
|
return a.pubkey;
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
const firstPubkey = pubkeys[0];
|
const firstPubkey = pubkeys[0];
|
||||||
const firstPubkeyProfile = useUserProfile(inView ? (firstPubkey === "anon" ? "" : firstPubkey) : "");
|
const firstPubkeyProfile = useUserProfile(inView ? (firstPubkey === "anon" ? "" : firstPubkey) : "");
|
||||||
@ -213,7 +213,7 @@ function NotificationGroup({ evs }: { evs: Array<TaggedNostrEvent> }) {
|
|||||||
pubkeys.length - 1,
|
pubkeys.length - 1,
|
||||||
firstPubkey === "anon"
|
firstPubkey === "anon"
|
||||||
? formatMessage({ defaultMessage: "Anon" })
|
? formatMessage({ defaultMessage: "Anon" })
|
||||||
: getDisplayName(firstPubkeyProfile, firstPubkey)
|
: getDisplayName(firstPubkeyProfile, firstPubkey),
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -221,7 +221,7 @@ export default function ProfilePage() {
|
|||||||
} as { [key: string]: Tab };
|
} as { [key: string]: Tab };
|
||||||
const [tab, setTab] = useState<Tab>(ProfileTab.Notes);
|
const [tab, setTab] = useState<Tab>(ProfileTab.Notes);
|
||||||
const optionalTabs = [ProfileTab.Zaps, ProfileTab.Relays, ProfileTab.Bookmarks, ProfileTab.Muted].filter(a =>
|
const optionalTabs = [ProfileTab.Zaps, ProfileTab.Relays, ProfileTab.Bookmarks, ProfileTab.Muted].filter(a =>
|
||||||
unwrap(a)
|
unwrap(a),
|
||||||
) as Tab[];
|
) as Tab[];
|
||||||
const horizontalScroll = useHorizontalScroll();
|
const horizontalScroll = useHorizontalScroll();
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ export default function ProfilePage() {
|
|||||||
type: TLVEntryType.Author,
|
type: TLVEntryType.Author,
|
||||||
length: 64,
|
length: 64,
|
||||||
value: id,
|
value: id,
|
||||||
})}`
|
})}`,
|
||||||
)
|
)
|
||||||
}>
|
}>
|
||||||
<Icon name="envelope" size={16} />
|
<Icon name="envelope" size={16} />
|
||||||
|
@ -73,7 +73,7 @@ export default function ZapPoolPage() {
|
|||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const zapPool = useSyncExternalStore(
|
const zapPool = useSyncExternalStore(
|
||||||
c => ZapPoolController.hook(c),
|
c => ZapPoolController.hook(c),
|
||||||
() => ZapPoolController.snapshot()
|
() => ZapPoolController.snapshot(),
|
||||||
);
|
);
|
||||||
const { wallet } = useWallet();
|
const { wallet } = useWallet();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export default function AccountsPage() {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown login error",
|
defaultMessage: "Unknown login error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
@ -29,7 +29,7 @@ export default function LNForwardAddress({ handle }: { handle: ManageHandle }) {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Invalid LNURL",
|
defaultMessage: "Invalid LNURL",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ const ConnectCashu = () => {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown error",
|
defaultMessage: "Unknown error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ const ConnectLNC = () => {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown error",
|
defaultMessage: "Unknown error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ const ConnectLNDHub = () => {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown error",
|
defaultMessage: "Unknown error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ const ConnectNostrWallet = () => {
|
|||||||
setError(
|
setError(
|
||||||
formatMessage({
|
formatMessage({
|
||||||
defaultMessage: "Unknown error",
|
defaultMessage: "Unknown error",
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ export default class SnortApi {
|
|||||||
path: string,
|
path: string,
|
||||||
method?: "GET" | string,
|
method?: "GET" | string,
|
||||||
body?: { [key: string]: string },
|
body?: { [key: string]: string },
|
||||||
headers?: { [key: string]: string }
|
headers?: { [key: string]: string },
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
if (!this.#publisher) {
|
if (!this.#publisher) {
|
||||||
throw new Error("Publisher not set");
|
throw new Error("Publisher not set");
|
||||||
@ -110,7 +110,7 @@ export default class SnortApi {
|
|||||||
path: string,
|
path: string,
|
||||||
method?: "GET" | string,
|
method?: "GET" | string,
|
||||||
body?: { [key: string]: string },
|
body?: { [key: string]: string },
|
||||||
headers?: { [key: string]: string }
|
headers?: { [key: string]: string },
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
const rsp = await fetch(`${this.#url}${path}`, {
|
const rsp = await fetch(`${this.#url}${path}`, {
|
||||||
method: method,
|
method: method,
|
||||||
|
@ -50,7 +50,7 @@ export async function openFile(): Promise<File | undefined> {
|
|||||||
}
|
}
|
||||||
}, 300);
|
}, 300);
|
||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ export function dedupeByPubkey(events: TaggedNostrEvent[]) {
|
|||||||
list: [...list, ev],
|
list: [...list, ev],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{ list: [], seen: new Set([]) }
|
{ list: [], seen: new Set([]) },
|
||||||
);
|
);
|
||||||
return deduped.list as TaggedNostrEvent[];
|
return deduped.list as TaggedNostrEvent[];
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ export function dedupeById<T extends { id: string }>(events: Array<T>) {
|
|||||||
list: [...list, ev],
|
list: [...list, ev],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{ list: [], seen: new Set([]) }
|
{ list: [], seen: new Set([]) },
|
||||||
);
|
);
|
||||||
return deduped.list as Array<T>;
|
return deduped.list as Array<T>;
|
||||||
}
|
}
|
||||||
@ -487,7 +487,7 @@ export function kvToObject<T>(o: string, sep?: string) {
|
|||||||
return [match[1], match[2]];
|
return [match[1], match[2]];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
})
|
}),
|
||||||
) as T;
|
) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ export const Toastore = new ToasterSlots();
|
|||||||
export default function Toaster() {
|
export default function Toaster() {
|
||||||
const toast = useSyncExternalStore(
|
const toast = useSyncExternalStore(
|
||||||
c => Toastore.hook(c),
|
c => Toastore.hook(c),
|
||||||
() => Toastore.snapshot()
|
() => Toastore.snapshot(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -12,7 +12,7 @@ import { magnetURIDecode } from "SnortUtils";
|
|||||||
export default async function VoidCatUpload(
|
export default async function VoidCatUpload(
|
||||||
file: File | Blob,
|
file: File | Blob,
|
||||||
filename: string,
|
filename: string,
|
||||||
publisher?: EventPublisher
|
publisher?: EventPublisher,
|
||||||
): Promise<UploadResult> {
|
): Promise<UploadResult> {
|
||||||
const api = new VoidApi(VoidCatHost);
|
const api = new VoidApi(VoidCatHost);
|
||||||
const uploader = api.getUploader(file);
|
const uploader = api.getUploader(file);
|
||||||
|
@ -57,6 +57,6 @@ export interface NutStashBackup {
|
|||||||
mints: [
|
mints: [
|
||||||
{
|
{
|
||||||
mintURL: string;
|
mintURL: string;
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ export class LNCWallet implements LNWallet {
|
|||||||
err => {
|
err => {
|
||||||
this.#log(err);
|
this.#log(err);
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ export class NostrConnectWallet implements LNWallet {
|
|||||||
],
|
],
|
||||||
() => {
|
() => {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
await this.#conn.SendAsync(evCommand);
|
await this.#conn.SendAsync(evCommand);
|
||||||
return await new Promise<T>((resolve, reject) => {
|
return await new Promise<T>((resolve, reject) => {
|
||||||
|
@ -84,7 +84,7 @@ export class WebLNWallet implements LNWallet {
|
|||||||
await window.webln?.makeInvoice({
|
await window.webln?.makeInvoice({
|
||||||
amount: req.amount,
|
amount: req.amount,
|
||||||
defaultMemo: req.memo,
|
defaultMemo: req.memo,
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
if (rsp) {
|
if (rsp) {
|
||||||
const invoice = prToWalletInvoice(rsp.paymentRequest);
|
const invoice = prToWalletInvoice(rsp.paymentRequest);
|
||||||
|
@ -248,7 +248,7 @@ window.document.addEventListener("close", () => {
|
|||||||
export function useWallet() {
|
export function useWallet() {
|
||||||
const wallet = useSyncExternalStore<WalletStoreSnapshot>(
|
const wallet = useSyncExternalStore<WalletStoreSnapshot>(
|
||||||
h => Wallets.hook(h),
|
h => Wallets.hook(h),
|
||||||
() => Wallets.snapshot()
|
() => Wallets.snapshot(),
|
||||||
);
|
);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (wallet.wallet?.isReady() === false && wallet.wallet.canAutoLogin()) {
|
if (wallet.wallet?.isReady() === false && wallet.wallet.canAutoLogin()) {
|
||||||
|
@ -54,7 +54,7 @@ class ZapPool extends ExternalStore<Array<ZapPoolRecipient>> {
|
|||||||
Toastore.push({
|
Toastore.push({
|
||||||
element: `Sent ${amtSend.toLocaleString()} sats to ${getDisplayName(
|
element: `Sent ${amtSend.toLocaleString()} sats to ${getDisplayName(
|
||||||
profile,
|
profile,
|
||||||
x.pubkey
|
x.pubkey,
|
||||||
)} from your zap pool`,
|
)} from your zap pool`,
|
||||||
expire: unixNow() + 10,
|
expire: unixNow() + 10,
|
||||||
icon: "zap",
|
icon: "zap",
|
||||||
|
@ -2,104 +2,113 @@ import { bytesToHex } from "@noble/hashes/utils";
|
|||||||
import { DefaultQueryOptimizer, FlatReqFilter, QueryOptimizer, ReqFilter } from "@snort/system";
|
import { DefaultQueryOptimizer, FlatReqFilter, QueryOptimizer, ReqFilter } from "@snort/system";
|
||||||
import { compress, expand_filter, flat_merge, get_diff, default as wasmInit } from "@snort/system-query";
|
import { compress, expand_filter, flat_merge, get_diff, default as wasmInit } from "@snort/system-query";
|
||||||
import WasmPath from "@snort/system-query/pkg/system_query_bg.wasm";
|
import WasmPath from "@snort/system-query/pkg/system_query_bg.wasm";
|
||||||
import { Bench } from 'tinybench';
|
import { Bench } from "tinybench";
|
||||||
|
|
||||||
const WasmQueryOptimizer = {
|
const WasmQueryOptimizer = {
|
||||||
expandFilter: (f: ReqFilter) => {
|
expandFilter: (f: ReqFilter) => {
|
||||||
return expand_filter(f) as Array<FlatReqFilter>;
|
return expand_filter(f) as Array<FlatReqFilter>;
|
||||||
},
|
},
|
||||||
getDiff: (prev: Array<ReqFilter>, next: Array<ReqFilter>) => {
|
getDiff: (prev: Array<ReqFilter>, next: Array<ReqFilter>) => {
|
||||||
return get_diff(prev, next) as Array<FlatReqFilter>;
|
return get_diff(prev, next) as Array<FlatReqFilter>;
|
||||||
},
|
},
|
||||||
flatMerge: (all: Array<FlatReqFilter>) => {
|
flatMerge: (all: Array<FlatReqFilter>) => {
|
||||||
return flat_merge(all) as Array<ReqFilter>;
|
return flat_merge(all) as Array<ReqFilter>;
|
||||||
},
|
},
|
||||||
compress: (all: Array<ReqFilter>) => {
|
compress: (all: Array<ReqFilter>) => {
|
||||||
return compress(all) as Array<ReqFilter>;
|
return compress(all) as Array<ReqFilter>;
|
||||||
}
|
},
|
||||||
} as QueryOptimizer;
|
} as QueryOptimizer;
|
||||||
|
|
||||||
const makeOnePubkey = () => {
|
|
||||||
const rnd = globalThis.crypto.getRandomValues(new Uint8Array(32));
|
|
||||||
return bytesToHex(rnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
const randomPubkeys = (() => {
|
const makeOnePubkey = () => {
|
||||||
const ret = [];
|
const rnd = globalThis.crypto.getRandomValues(new Uint8Array(32));
|
||||||
for(let x =0;x<50;x++) {
|
return bytesToHex(rnd);
|
||||||
ret.push(makeOnePubkey());
|
};
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
})();
|
|
||||||
|
|
||||||
const testExpand = (q: QueryOptimizer) => {
|
const randomPubkeys = (() => {
|
||||||
q.expandFilter({
|
const ret = [];
|
||||||
kinds: [1,2,3],
|
for (let x = 0; x < 50; x++) {
|
||||||
authors: randomPubkeys
|
ret.push(makeOnePubkey());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
const testGetDiff = (q: QueryOptimizer) => {
|
return ret;
|
||||||
q.getDiff([{
|
})();
|
||||||
|
|
||||||
|
const testExpand = (q: QueryOptimizer) => {
|
||||||
|
q.expandFilter({
|
||||||
|
kinds: [1, 2, 3],
|
||||||
|
authors: randomPubkeys,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const testGetDiff = (q: QueryOptimizer) => {
|
||||||
|
q.getDiff(
|
||||||
|
[
|
||||||
|
{
|
||||||
kinds: [1, 2, 3],
|
kinds: [1, 2, 3],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
}], [{
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
kinds: [1, 2, 3, 4, 5],
|
kinds: [1, 2, 3, 4, 5],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
}]);
|
},
|
||||||
}
|
],
|
||||||
|
);
|
||||||
|
};
|
||||||
const testFlatMerge = (q: QueryOptimizer) => {
|
const testFlatMerge = (q: QueryOptimizer) => {
|
||||||
q.flatMerge(q.expandFilter({
|
q.flatMerge(
|
||||||
kinds: [1, 6, 7, 6969],
|
q.expandFilter({
|
||||||
authors: randomPubkeys
|
kinds: [1, 6, 7, 6969],
|
||||||
}));
|
authors: randomPubkeys,
|
||||||
}
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
const testCompress = (q: QueryOptimizer) => {
|
const testCompress = (q: QueryOptimizer) => {
|
||||||
q.compress([
|
q.compress([
|
||||||
{
|
{
|
||||||
kinds: [1, 6, 7, 6969],
|
kinds: [1, 6, 7, 6969],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [1, 6, 7, 6969],
|
kinds: [1, 6, 7, 6969],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [1, 6, 7, 6969],
|
kinds: [1, 6, 7, 6969],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [1, 6, 7, 6969],
|
kinds: [1, 6, 7, 6969],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [1, 6, 7, 6969],
|
kinds: [1, 6, 7, 6969],
|
||||||
authors: randomPubkeys
|
authors: randomPubkeys,
|
||||||
}
|
},
|
||||||
])
|
]);
|
||||||
}
|
};
|
||||||
|
|
||||||
const wasmSuite = new Bench({ time: 1_000 });
|
const wasmSuite = new Bench({ time: 1_000 });
|
||||||
const suite = new Bench({ time: 1_000 });
|
const suite = new Bench({ time: 1_000 });
|
||||||
|
|
||||||
const addTests = (s: Bench, q: QueryOptimizer) => {
|
const addTests = (s: Bench, q: QueryOptimizer) => {
|
||||||
s.add("expand", () => testExpand(q));
|
s.add("expand", () => testExpand(q));
|
||||||
s.add("get_diff", () => testGetDiff(q));
|
s.add("get_diff", () => testGetDiff(q));
|
||||||
s.add("flat_merge", () => testFlatMerge(q));
|
s.add("flat_merge", () => testFlatMerge(q));
|
||||||
s.add("compress", () => testCompress(q));
|
s.add("compress", () => testCompress(q));
|
||||||
}
|
};
|
||||||
|
|
||||||
addTests(suite, DefaultQueryOptimizer);
|
|
||||||
addTests(wasmSuite, WasmQueryOptimizer);
|
|
||||||
|
|
||||||
const runAll = async() => {
|
|
||||||
await wasmInit(WasmPath);
|
|
||||||
|
|
||||||
console.log("DefaultQueryOptimizer");
|
addTests(suite, DefaultQueryOptimizer);
|
||||||
await suite.run();
|
addTests(wasmSuite, WasmQueryOptimizer);
|
||||||
console.table(suite.table());
|
|
||||||
|
|
||||||
console.log("WasmQueryOptimizer");
|
const runAll = async () => {
|
||||||
await wasmSuite.run();
|
await wasmInit(WasmPath);
|
||||||
console.table(wasmSuite.table());
|
|
||||||
};
|
console.log("DefaultQueryOptimizer");
|
||||||
runAll().catch(console.error);
|
await suite.run();
|
||||||
|
console.table(suite.table());
|
||||||
|
|
||||||
|
console.log("WasmQueryOptimizer");
|
||||||
|
await wasmSuite.run();
|
||||||
|
console.table(wasmSuite.table());
|
||||||
|
};
|
||||||
|
runAll().catch(console.error);
|
||||||
|
@ -116,7 +116,7 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
|||||||
type: TLVEntryType.Author,
|
type: TLVEntryType.Author,
|
||||||
length: params[0].length,
|
length: params[0].length,
|
||||||
value: params[0],
|
value: params[0],
|
||||||
} as TLVEntry
|
} as TLVEntry,
|
||||||
)}`;
|
)}`;
|
||||||
}
|
}
|
||||||
case ChatType.PrivateDirectMessage: {
|
case ChatType.PrivateDirectMessage: {
|
||||||
@ -127,7 +127,7 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
|||||||
type: TLVEntryType.Author,
|
type: TLVEntryType.Author,
|
||||||
length: params[0].length,
|
length: params[0].length,
|
||||||
value: params[0],
|
value: params[0],
|
||||||
} as TLVEntry
|
} as TLVEntry,
|
||||||
)}`;
|
)}`;
|
||||||
}
|
}
|
||||||
case ChatType.PrivateGroupChat: {
|
case ChatType.PrivateGroupChat: {
|
||||||
@ -139,8 +139,8 @@ export function createChatLink(type: ChatType, ...params: Array<string>) {
|
|||||||
type: TLVEntryType.Author,
|
type: TLVEntryType.Author,
|
||||||
length: a.length,
|
length: a.length,
|
||||||
value: a,
|
value: a,
|
||||||
} as TLVEntry)
|
}) as TLVEntry,
|
||||||
)
|
),
|
||||||
)}`;
|
)}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,14 +161,14 @@ export function useNip4Chat() {
|
|||||||
const { publicKey } = useLogin();
|
const { publicKey } = useLogin();
|
||||||
return useSyncExternalStore(
|
return useSyncExternalStore(
|
||||||
c => Nip4Chats.hook(c),
|
c => Nip4Chats.hook(c),
|
||||||
() => Nip4Chats.snapshot(publicKey)
|
() => Nip4Chats.snapshot(publicKey),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useNip29Chat() {
|
export function useNip29Chat() {
|
||||||
return useSyncExternalStore(
|
return useSyncExternalStore(
|
||||||
c => Nip29Chats.hook(c),
|
c => Nip29Chats.hook(c),
|
||||||
() => Nip29Chats.snapshot()
|
() => Nip29Chats.snapshot(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ export function useNip24Chat() {
|
|||||||
const { publicKey } = useLogin();
|
const { publicKey } = useLogin();
|
||||||
return useSyncExternalStore(
|
return useSyncExternalStore(
|
||||||
c => Nip24Chats.hook(c),
|
c => Nip24Chats.hook(c),
|
||||||
() => Nip24Chats.snapshot(publicKey)
|
() => Nip24Chats.snapshot(publicKey),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
|||||||
value: v,
|
value: v,
|
||||||
type: TLVEntryType.Author,
|
type: TLVEntryType.Author,
|
||||||
length: v.length,
|
length: v.length,
|
||||||
} as TLVEntry)
|
}) as TLVEntry,
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
return dedupe(messages.map(a => chatId(a))).map(a => {
|
return dedupe(messages.map(a => chatId(a))).map(a => {
|
||||||
@ -72,7 +72,7 @@ export class Nip24ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
|||||||
} as {
|
} as {
|
||||||
t: number;
|
t: number;
|
||||||
title: string | undefined;
|
title: string | undefined;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
type: ChatType.PrivateDirectMessage,
|
type: ChatType.PrivateDirectMessage,
|
||||||
|
@ -46,12 +46,12 @@ export class Nip29ChatSystem extends ExternalStore<Array<Chat>> implements ChatS
|
|||||||
.map(a => a.tags.find(b => b[0] === "g"))
|
.map(a => a.tags.find(b => b[0] === "g"))
|
||||||
.filter(a => a !== undefined)
|
.filter(a => a !== undefined)
|
||||||
.map(a => unwrap(a))
|
.map(a => unwrap(a))
|
||||||
.map(a => `${a[2]}${a[1]}`)
|
.map(a => `${a[2]}${a[1]}`),
|
||||||
);
|
);
|
||||||
return groups.map(g => {
|
return groups.map(g => {
|
||||||
const [relay, channel] = g.split("/", 2);
|
const [relay, channel] = g.split("/", 2);
|
||||||
const messages = allMessages.filter(
|
const messages = allMessages.filter(
|
||||||
a => `${a.tags.find(b => b[0] === "g")?.[2]}${a.tags.find(b => b[0] === "g")?.[1]}` === g
|
a => `${a.tags.find(b => b[0] === "g")?.[2]}${a.tags.find(b => b[0] === "g")?.[1]}` === g,
|
||||||
);
|
);
|
||||||
const lastRead = lastReadInChat(g);
|
const lastRead = lastReadInChat(g);
|
||||||
return {
|
return {
|
||||||
|
@ -34,7 +34,7 @@ export class Nip4ChatSystem extends ExternalStore<Array<Chat>> implements ChatSy
|
|||||||
const dms = this.#cache.snapshot();
|
const dms = this.#cache.snapshot();
|
||||||
const dmSince = dms.reduce(
|
const dmSince = dms.reduce(
|
||||||
(acc, v) => (v.created_at > acc && v.kind === EventKind.DirectMessage ? (acc = v.created_at) : acc),
|
(acc, v) => (v.created_at > acc && v.kind === EventKind.DirectMessage ? (acc = v.created_at) : acc),
|
||||||
0
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
this.#log("Loading DMS since %s", new Date(dmSince * 1000));
|
this.#log("Loading DMS since %s", new Date(dmSince * 1000));
|
||||||
@ -49,12 +49,15 @@ export class Nip4ChatSystem extends ExternalStore<Array<Chat>> implements ChatSy
|
|||||||
|
|
||||||
listChats(pk: string): Chat[] {
|
listChats(pk: string): Chat[] {
|
||||||
const myDms = this.#nip4Events();
|
const myDms = this.#nip4Events();
|
||||||
const chats = myDms.reduce((acc, v) => {
|
const chats = myDms.reduce(
|
||||||
const chatId = inChatWith(v, pk);
|
(acc, v) => {
|
||||||
acc[chatId] ??= [];
|
const chatId = inChatWith(v, pk);
|
||||||
acc[chatId].push(v);
|
acc[chatId] ??= [];
|
||||||
return acc;
|
acc[chatId].push(v);
|
||||||
}, {} as Record<string, Array<NostrEvent>>);
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, Array<NostrEvent>>,
|
||||||
|
);
|
||||||
|
|
||||||
return [...Object.entries(chats)].map(([k, v]) => Nip4ChatSystem.createChatObj(k, v));
|
return [...Object.entries(chats)].map(([k, v]) => Nip4ChatSystem.createChatObj(k, v));
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,16 @@ import { StrictMode } from "react";
|
|||||||
import * as ReactDOM from "react-dom/client";
|
import * as ReactDOM from "react-dom/client";
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
import { EventPublisher, NostrSystem, ProfileLoaderService, Nip7Signer, PowWorker, QueryOptimizer, FlatReqFilter, ReqFilter } from "@snort/system";
|
import {
|
||||||
|
EventPublisher,
|
||||||
|
NostrSystem,
|
||||||
|
ProfileLoaderService,
|
||||||
|
Nip7Signer,
|
||||||
|
PowWorker,
|
||||||
|
QueryOptimizer,
|
||||||
|
FlatReqFilter,
|
||||||
|
ReqFilter,
|
||||||
|
} from "@snort/system";
|
||||||
import { SnortContext } from "@snort/system-react";
|
import { SnortContext } from "@snort/system-react";
|
||||||
|
|
||||||
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
|
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
|
||||||
@ -51,7 +60,7 @@ const WasmQueryOptimizer = {
|
|||||||
},
|
},
|
||||||
compress: (all: Array<ReqFilter>) => {
|
compress: (all: Array<ReqFilter>) => {
|
||||||
return compress(all) as Array<ReqFilter>;
|
return compress(all) as Array<ReqFilter>;
|
||||||
}
|
},
|
||||||
} as QueryOptimizer;
|
} as QueryOptimizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,5 +202,5 @@ root.render(
|
|||||||
</SnortContext.Provider>
|
</SnortContext.Provider>
|
||||||
</IntlProvider>
|
</IntlProvider>
|
||||||
</Provider>
|
</Provider>
|
||||||
</StrictMode>
|
</StrictMode>,
|
||||||
);
|
);
|
||||||
|
@ -19,7 +19,7 @@ const config = {
|
|||||||
import: require.resolve("@snort/system/dist/pow-worker.js"),
|
import: require.resolve("@snort/system/dist/pow-worker.js"),
|
||||||
filename: "pow.js",
|
filename: "pow.js",
|
||||||
},
|
},
|
||||||
bench: "./src/benchmarks.ts"
|
bench: "./src/benchmarks.ts",
|
||||||
},
|
},
|
||||||
target: "browserslist",
|
target: "browserslist",
|
||||||
mode: isProduction ? "production" : "development",
|
mode: isProduction ? "production" : "development",
|
||||||
@ -156,7 +156,7 @@ const config = {
|
|||||||
extensions: ["...", ".tsx", ".ts", ".jsx", ".js"],
|
extensions: ["...", ".tsx", ".ts", ".jsx", ".js"],
|
||||||
modules: ["...", __dirname, path.resolve(__dirname, "src")],
|
modules: ["...", __dirname, path.resolve(__dirname, "src")],
|
||||||
fallback: { crypto: false },
|
fallback: { crypto: false },
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = () => config;
|
module.exports = () => config;
|
||||||
|
@ -11,4 +11,4 @@
|
|||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
"./snippets/*"
|
"./snippets/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
64
packages/system-query/pkg/system_query.d.ts
vendored
64
packages/system-query/pkg/system_query.d.ts
vendored
@ -1,31 +1,31 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/**
|
/**
|
||||||
* @param {any} prev
|
* @param {any} prev
|
||||||
* @param {any} next
|
* @param {any} next
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export function diff_filters(prev: any, next: any): any;
|
export function diff_filters(prev: any, next: any): any;
|
||||||
/**
|
/**
|
||||||
* @param {any} val
|
* @param {any} val
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export function expand_filter(val: any): any;
|
export function expand_filter(val: any): any;
|
||||||
/**
|
/**
|
||||||
* @param {any} prev
|
* @param {any} prev
|
||||||
* @param {any} next
|
* @param {any} next
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export function get_diff(prev: any, next: any): any;
|
export function get_diff(prev: any, next: any): any;
|
||||||
/**
|
/**
|
||||||
* @param {any} val
|
* @param {any} val
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export function flat_merge(val: any): any;
|
export function flat_merge(val: any): any;
|
||||||
/**
|
/**
|
||||||
* @param {any} val
|
* @param {any} val
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
export function compress(val: any): any;
|
export function compress(val: any): any;
|
||||||
|
|
||||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
||||||
@ -45,21 +45,21 @@ export interface InitOutput {
|
|||||||
|
|
||||||
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
||||||
/**
|
/**
|
||||||
* Instantiates the given `module`, which can either be bytes or
|
* Instantiates the given `module`, which can either be bytes or
|
||||||
* a precompiled `WebAssembly.Module`.
|
* a precompiled `WebAssembly.Module`.
|
||||||
*
|
*
|
||||||
* @param {SyncInitInput} module
|
* @param {SyncInitInput} module
|
||||||
*
|
*
|
||||||
* @returns {InitOutput}
|
* @returns {InitOutput}
|
||||||
*/
|
*/
|
||||||
export function initSync(module: SyncInitInput): InitOutput;
|
export function initSync(module: SyncInitInput): InitOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||||
* for everything else, calls `WebAssembly.instantiate` directly.
|
* for everything else, calls `WebAssembly.instantiate` directly.
|
||||||
*
|
*
|
||||||
* @param {InitInput | Promise<InitInput>} module_or_path
|
* @param {InitInput | Promise<InitInput>} module_or_path
|
||||||
*
|
*
|
||||||
* @returns {Promise<InitOutput>}
|
* @returns {Promise<InitOutput>}
|
||||||
*/
|
*/
|
||||||
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
export default function __wbg_init(module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -134,4 +134,4 @@ export interface MessageEncryptor {
|
|||||||
getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array> | Uint8Array;
|
getSharedSecret(privateKey: string, publicKey: string): Promise<Uint8Array> | Uint8Array;
|
||||||
encryptData(plaintext: string, sharedSecet: Uint8Array): Promise<MessageEncryptorPayload> | MessageEncryptorPayload;
|
encryptData(plaintext: string, sharedSecet: Uint8Array): Promise<MessageEncryptorPayload> | MessageEncryptorPayload;
|
||||||
decryptData(payload: MessageEncryptorPayload, sharedSecet: Uint8Array): Promise<string> | string;
|
decryptData(payload: MessageEncryptorPayload, sharedSecet: Uint8Array): Promise<string> | string;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
|
|||||||
this.#profileCache = props.profileCache ?? new UserProfileCache();
|
this.#profileCache = props.profileCache ?? new UserProfileCache();
|
||||||
this.#relayMetricsCache = props.relayMetrics ?? new RelayMetricCache();
|
this.#relayMetricsCache = props.relayMetrics ?? new RelayMetricCache();
|
||||||
this.#eventsCache = props.eventsCache ?? new EventsCache();
|
this.#eventsCache = props.eventsCache ?? new EventsCache();
|
||||||
this.#queryOptimizer = props.queryOptimizer ?? DefaultQueryOptimizer;
|
this.#queryOptimizer = props.queryOptimizer ?? DefaultQueryOptimizer;
|
||||||
|
|
||||||
this.#profileLoader = new ProfileLoaderService(this, this.#profileCache);
|
this.#profileLoader = new ProfileLoaderService(this, this.#profileCache);
|
||||||
this.#relayMetrics = new RelayMetricHandler(this.#relayMetricsCache);
|
this.#relayMetrics = new RelayMetricHandler(this.#relayMetricsCache);
|
||||||
@ -254,9 +254,7 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
|
|||||||
if (existing.fromInstance === req.instance) {
|
if (existing.fromInstance === req.instance) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
const filters = !req.options?.skipDiff
|
const filters = !req.options?.skipDiff ? req.buildDiff(this, existing.filters) : req.build(this);
|
||||||
? req.buildDiff(this, existing.filters)
|
|
||||||
: req.build(this);
|
|
||||||
if (filters.length === 0 && !!req.options?.skipDiff) {
|
if (filters.length === 0 && !!req.options?.skipDiff) {
|
||||||
return existing;
|
return existing;
|
||||||
} else {
|
} else {
|
||||||
@ -275,7 +273,7 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
|
|||||||
const expectIds = new Set(filters.flatMap(a => a.filters).flatMap(a => a.ids ?? []));
|
const expectIds = new Set(filters.flatMap(a => a.filters).flatMap(a => a.ids ?? []));
|
||||||
q.feed.onEvent(async evs => {
|
q.feed.onEvent(async evs => {
|
||||||
const toSet = evs.filter(a => expectIds.has(a.id) && this.#eventsCache.getFromCache(a.id) === undefined);
|
const toSet = evs.filter(a => expectIds.has(a.id) && this.#eventsCache.getFromCache(a.id) === undefined);
|
||||||
if(toSet.length > 0) {
|
if (toSet.length > 0) {
|
||||||
await this.#eventsCache.bulkSet(toSet);
|
await this.#eventsCache.bulkSet(toSet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -411,4 +409,4 @@ export class NostrSystem extends ExternalStore<SystemSnapshot> implements System
|
|||||||
}
|
}
|
||||||
setTimeout(() => this.#cleanup(), 1_000);
|
setTimeout(() => this.#cleanup(), 1_000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ReqFilter } from "../nostr"
|
import { ReqFilter } from "../nostr";
|
||||||
import { expandFilter } from "./request-expander"
|
import { expandFilter } from "./request-expander";
|
||||||
import { flatMerge, mergeSimilar } from "./request-merger"
|
import { flatMerge, mergeSimilar } from "./request-merger";
|
||||||
import { diffFilters } from "./request-splitter"
|
import { diffFilters } from "./request-splitter";
|
||||||
|
|
||||||
export interface FlatReqFilter {
|
export interface FlatReqFilter {
|
||||||
keys: number;
|
keys: number;
|
||||||
@ -20,24 +20,27 @@ export interface FlatReqFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryOptimizer {
|
export interface QueryOptimizer {
|
||||||
expandFilter(f: ReqFilter): Array<FlatReqFilter>
|
expandFilter(f: ReqFilter): Array<FlatReqFilter>;
|
||||||
getDiff(prev: Array<ReqFilter>, next: Array<ReqFilter>): Array<FlatReqFilter>
|
getDiff(prev: Array<ReqFilter>, next: Array<ReqFilter>): Array<FlatReqFilter>;
|
||||||
flatMerge(all: Array<FlatReqFilter>): Array<ReqFilter>
|
flatMerge(all: Array<FlatReqFilter>): Array<ReqFilter>;
|
||||||
compress(all: Array<ReqFilter>): Array<ReqFilter>
|
compress(all: Array<ReqFilter>): Array<ReqFilter>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DefaultQueryOptimizer = {
|
export const DefaultQueryOptimizer = {
|
||||||
expandFilter: (f: ReqFilter) => {
|
expandFilter: (f: ReqFilter) => {
|
||||||
return expandFilter(f);
|
return expandFilter(f);
|
||||||
},
|
},
|
||||||
getDiff: (prev: Array<ReqFilter>, next: Array<ReqFilter>) => {
|
getDiff: (prev: Array<ReqFilter>, next: Array<ReqFilter>) => {
|
||||||
const diff = diffFilters(prev.flatMap(a => expandFilter(a)), next.flatMap(a => expandFilter(a)));
|
const diff = diffFilters(
|
||||||
return diff.added;
|
prev.flatMap(a => expandFilter(a)),
|
||||||
},
|
next.flatMap(a => expandFilter(a)),
|
||||||
flatMerge: (all: Array<FlatReqFilter>) => {
|
);
|
||||||
return flatMerge(all);
|
return diff.added;
|
||||||
},
|
},
|
||||||
compress: (all: Array<ReqFilter>) => {
|
flatMerge: (all: Array<FlatReqFilter>) => {
|
||||||
return mergeSimilar(all);
|
return flatMerge(all);
|
||||||
}
|
},
|
||||||
} as QueryOptimizer;
|
compress: (all: Array<ReqFilter>) => {
|
||||||
|
return mergeSimilar(all);
|
||||||
|
},
|
||||||
|
} as QueryOptimizer;
|
||||||
|
@ -29,4 +29,4 @@ export function diffFilters(prev: Array<FlatReqFilter>, next: Array<FlatReqFilte
|
|||||||
removed: changed ? removed : [],
|
removed: changed ? removed : [],
|
||||||
changed,
|
changed,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export class SystemWorker extends ExternalStore<SystemSnapshot> implements Syste
|
|||||||
get RelayCache(): RelayCache {
|
get RelayCache(): RelayCache {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
get QueryOptimizer(): QueryOptimizer {
|
get QueryOptimizer(): QueryOptimizer {
|
||||||
throw new Error("Method not implemented.");
|
throw new Error("Method not implemented.");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ function getInvoice(zap: NostrEvent): InvoiceDetails | undefined {
|
|||||||
|
|
||||||
export function parseZap(zapReceipt: NostrEvent, userCache: FeedCache<MetadataCache>, refNote?: NostrEvent): ParsedZap {
|
export function parseZap(zapReceipt: NostrEvent, userCache: FeedCache<MetadataCache>, refNote?: NostrEvent): ParsedZap {
|
||||||
const existing = ParsedZapCache.get(zapReceipt.id);
|
const existing = ParsedZapCache.get(zapReceipt.id);
|
||||||
if(existing) {
|
if (existing) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import {NostrSystem, SystemInterface} from "..";
|
import { NostrSystem, SystemInterface } from "..";
|
||||||
|
|
||||||
const Relay = "wss://relay.snort.social/";
|
const Relay = "wss://relay.snort.social/";
|
||||||
|
|
||||||
const system = new NostrSystem({}) as SystemInterface;
|
const system = new NostrSystem({}) as SystemInterface;
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
await system.ConnectToRelay(Relay, {read: true, write: true});
|
await system.ConnectToRelay(Relay, { read: true, write: true });
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
system.DisconnectRelay(Relay);
|
system.DisconnectRelay(Relay);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
test().catch(console.error);
|
test().catch(console.error);
|
||||||
|
@ -2852,6 +2852,7 @@ __metadata:
|
|||||||
"@peculiar/webcrypto": ^1.4.3
|
"@peculiar/webcrypto": ^1.4.3
|
||||||
"@scure/base": ^1.1.2
|
"@scure/base": ^1.1.2
|
||||||
"@snort/shared": ^1.0.5
|
"@snort/shared": ^1.0.5
|
||||||
|
"@snort/system-query": "workspace:*"
|
||||||
"@stablelib/xchacha20": ^1.0.1
|
"@stablelib/xchacha20": ^1.0.1
|
||||||
"@types/debug": ^4.1.8
|
"@types/debug": ^4.1.8
|
||||||
"@types/jest": ^29.5.1
|
"@types/jest": ^29.5.1
|
||||||
|
Loading…
Reference in New Issue
Block a user