bug: tryParseNostrLink

This commit is contained in:
2023-06-13 14:46:16 +01:00
parent fdf3d855df
commit 7992601f46
6 changed files with 18 additions and 20 deletions

View File

@ -1,11 +1,11 @@
import { Link } from "react-router-dom";
import { NostrPrefix, parseNostrLink } from "@snort/system";
import { NostrPrefix, tryParseNostrLink } from "@snort/system";
import Mention from "Element/Mention";
import NoteQuote from "Element/NoteQuote";
export default function NostrLink({ link, depth }: { link: string; depth?: number }) {
const nav = parseNostrLink(link);
const nav = tryParseNostrLink(link);
if (nav?.type === NostrPrefix.PublicKey || nav?.type === NostrPrefix.Profile) {
return <Mention pubkey={nav.id} relays={nav.relays} />;

View File

@ -218,9 +218,9 @@ export default function Thread() {
const location = useLocation();
const link = parseNostrLink(params.id ?? "", NostrPrefix.Note);
const thread = useThreadFeed(unwrap(link));
const thread = useThreadFeed(link);
const [currentId, setCurrentId] = useState(link?.id);
const [currentId, setCurrentId] = useState(link.id);
const navigate = useNavigate();
const isSingleNote = thread.data?.filter(a => a.kind === EventKind.TextNote).length === 1;

View File

@ -2,7 +2,7 @@ import "./ProfilePage.css";
import { useEffect, useState } from "react";
import { useIntl, FormattedMessage } from "react-intl";
import { useNavigate, useParams } from "react-router-dom";
import { encodeTLV, EventKind, HexKey, NostrPrefix, parseNostrLink } from "@snort/system";
import { encodeTLV, EventKind, HexKey, NostrPrefix, tryParseNostrLink } from "@snort/system";
import { getReactions, unwrap } from "SnortUtils";
import { formatShort } from "Number";
@ -157,7 +157,7 @@ export default function ProfilePage() {
setId(a);
});
} else {
const nav = parseNostrLink(params.id ?? "");
const nav = tryParseNostrLink(params.id ?? "");
if (nav?.type === NostrPrefix.PublicKey || nav?.type === NostrPrefix.Profile) {
// todo: use relays if any for nprofile
setId(nav.id);