Merge branch 'v0l:main' into main

This commit is contained in:
gandlafbtc
2023-02-17 11:12:55 +01:00
committed by GitHub
12 changed files with 119 additions and 29 deletions

View File

@ -1,7 +0,0 @@
node_modules/
.github/
.vscode/
build/
yarn-error.log
.husky/
.git/

View File

@ -154,6 +154,10 @@
font-feature-settings: "tnum";
}
.reaction-pill-icon {
margin: auto;
}
.reaction-pill .reaction-pill-number {
margin-left: 8px;
font-feature-settings: "tnum";
@ -216,3 +220,15 @@
.note .reactions-link:hover {
text-decoration: underline;
}
.close-menu {
position: absolute;
width: 100vw;
height: 100vh;
top: -400px;
left: -600px;
}
.close-menu-container {
position: absolute;
}

View File

@ -209,6 +209,13 @@ export default function NoteFooter(props: NoteFooterProps) {
function menuItems() {
return (
<>
<div className="close-menu-container">
{/* This menu item serves as a "close menu" button;
it allows the user to click anywhere nearby the menu to close it. */}
<MenuItem>
<div className="close-menu" />
</MenuItem>
</div>
{prefs.enableReactions && (
<MenuItem onClick={() => setShowReactions(true)}>
<Heart />

View File

@ -23,6 +23,10 @@ function findTag(e: TaggedRawEvent, tag: string) {
function getInvoice(zap: TaggedRawEvent) {
const bolt11 = findTag(zap, "bolt11");
if (!bolt11) {
console.debug("Invalid zap: ", zap);
return {};
}
const decoded = invoiceDecode(bolt11);
const amount = decoded.sections.find(section => section.name === "amount")?.value;
@ -66,6 +70,7 @@ export interface ParsedZap {
content: string;
zapper?: HexKey;
valid: boolean;
zapService: HexKey;
}
export function parseZap(zap: TaggedRawEvent): ParsedZap {
@ -81,6 +86,7 @@ export function parseZap(zap: TaggedRawEvent): ParsedZap {
zapper: zapper.pubkey,
content: zap.content,
valid: zapper.isValid,
zapService: zap.pubkey,
};
}

View File

@ -1,20 +1,42 @@
import { NostrPrefix } from "@snort/nostr";
import { decodeTLV, NostrPrefix, TLVEntryType } from "@snort/nostr";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import { useNavigate, useParams } from "react-router-dom";
import { setRelays } from "State/Login";
import { eventLink, profileLink } from "Util";
export default function NostrLinkHandler() {
const params = useParams();
const dispatch = useDispatch();
const navigate = useNavigate();
const link = decodeURIComponent(params["*"] ?? "");
const link = decodeURIComponent(params["*"] ?? "").toLowerCase();
useEffect(() => {
if (link.length > 0) {
const ls = link.split(":");
const entity = ls[1];
if (entity.startsWith(NostrPrefix.PublicKey) || entity.startsWith(NostrPrefix.Profile)) {
const entity = link.startsWith("web+nostr:") ? link.split(":")[1] : link;
if (entity.startsWith(NostrPrefix.PublicKey)) {
navigate(`/p/${entity}`);
} else if (entity.startsWith(NostrPrefix.Event) || entity.startsWith(NostrPrefix.Note)) {
} else if (entity.startsWith(NostrPrefix.Note)) {
navigate(`/e/${entity}`);
} else if (entity.startsWith(NostrPrefix.Profile) || entity.startsWith(NostrPrefix.Event)) {
const decoded = decodeTLV(entity);
console.debug(decoded);
const id = decoded.find(a => a.type === TLVEntryType.Special)?.value as string;
const relays = decoded.filter(a => a.type === TLVEntryType.Relay);
if (relays.length > 0) {
const relayObj = {
relays: Object.fromEntries(relays.map(a => [a.value, { read: true, write: false }])),
createdAt: new Date().getTime(),
};
dispatch(setRelays(relayObj));
}
if (entity.startsWith(NostrPrefix.Profile)) {
navigate(profileLink(id));
} else if (entity.startsWith(NostrPrefix.Event)) {
navigate(eventLink(id));
}
}
}
}, [link]);

View File

@ -75,6 +75,8 @@ export default function ProfilePage() {
users: new Map(),
creator: "",
});
const npub = !id.startsWith("npub") ? hexToBech32("npub", id || undefined) : id;
const lnurl = extractLnAddress(user?.lud16 || user?.lud06 || "");
const website_url =
user?.website && !user.website.startsWith("http") ? "https://" + user.website : user?.website || "";
@ -121,7 +123,7 @@ export default function ProfilePage() {
<FollowsYou followsMe={follows.includes(id)} />
</h2>
{user?.nip05 && <Nip05 nip05={user.nip05} pubkey={user.pubkey} />}
<Copy text={params.id || ""} />
<Copy text={npub} />
{links()}
</div>
);

View File

@ -86,16 +86,15 @@ export default function RootPage() {
return (
<>
<div className="main-content">{pubKey && <Tabs tabs={tabs} tab={tab} setTab={setTab} />}</div>
{isGlobal && globalRelays.length > 0 && (
<div className="flex mb10">
<div className="f-grow">
<div className="main-content">
{pubKey && <Tabs tabs={tabs} tab={tab} setTab={setTab} />}
{isGlobal && globalRelays.length > 0 && (
<div className="flex mb10 f-end">
<FormattedMessage
defaultMessage="Read global from"
description="Label for reading global feed from specific relays"
/>
</div>
<div>
&nbsp;
<select onChange={e => setRelay(e.target.value)}>
{globalRelays.map(a => (
<option key={a} value={a}>
@ -104,8 +103,8 @@ export default function RootPage() {
))}
</select>
</div>
</div>
)}
)}
</div>
{followHints()}
<Timeline
key={tab.value}

View File

@ -41,7 +41,7 @@ export function parseId(id: string) {
}
export function bech32ToHex(str: string) {
const nKey = bech32.decode(str);
const nKey = bech32.decode(str, 1_000);
const buff = bech32.fromWords(nKey.words);
return secp.utils.bytesToHex(Uint8Array.from(buff));
}