bugfixes
This commit is contained in:
parent
3bbad28c32
commit
5521f685fc
@ -27,9 +27,10 @@ import MagnetLink from "Element/MagnetLink";
|
||||
interface HypeTextProps {
|
||||
link: string;
|
||||
depth?: number;
|
||||
showLinkPreview?: boolean;
|
||||
}
|
||||
|
||||
export default function HyperText({ link, depth }: HypeTextProps) {
|
||||
export default function HyperText({ link, depth, showLinkPreview }: HypeTextProps) {
|
||||
const a = link;
|
||||
try {
|
||||
const url = new URL(a);
|
||||
@ -91,7 +92,7 @@ export default function HyperText({ link, depth }: HypeTextProps) {
|
||||
if (parsed) {
|
||||
return <MagnetLink magnet={parsed} />;
|
||||
}
|
||||
} else {
|
||||
} else if (showLinkPreview ?? true) {
|
||||
return <LinkPreview url={a} />;
|
||||
}
|
||||
} catch {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "./NoteReaction.css";
|
||||
import { Link } from "react-router-dom";
|
||||
import { useMemo } from "react";
|
||||
import { EventKind, NostrEvent, TaggedNostrEvent, NostrPrefix } from "@snort/system";
|
||||
import { EventKind, NostrEvent, TaggedNostrEvent, NostrPrefix, EventExt } from "@snort/system";
|
||||
|
||||
import Note from "Element/Note";
|
||||
import { getDisplayName } from "Element/ProfileImage";
|
||||
@ -46,6 +46,11 @@ export default function NoteReaction(props: NoteReactionProps) {
|
||||
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
|
||||
try {
|
||||
const r: NostrEvent = JSON.parse(ev.content);
|
||||
EventExt.fixupEvent(r);
|
||||
if(!EventExt.verify(r)) {
|
||||
console.debug("Event in repost is invalid");
|
||||
return undefined;
|
||||
}
|
||||
return r as TaggedNostrEvent;
|
||||
} catch (e) {
|
||||
console.error("Could not load reposted content", e);
|
||||
|
@ -63,7 +63,7 @@ export default function Text({ content, tags, creator, disableMedia, depth, disa
|
||||
return <CashuNuts token={a.content} />;
|
||||
case "media":
|
||||
case "link":
|
||||
return <HyperText link={a.content} depth={depth} />;
|
||||
return <HyperText link={a.content} depth={depth} showLinkPreview={!(disableMedia ?? false)}/>;
|
||||
case "custom_emoji":
|
||||
return <ProxyImg src={a.content} size={15} className="custom-emoji" />;
|
||||
default:
|
||||
|
@ -121,8 +121,9 @@ export default function ProfilePage() {
|
||||
const about = Text({
|
||||
content: aboutText,
|
||||
tags: [],
|
||||
creator: "",
|
||||
creator: id ?? "",
|
||||
disableMedia: true,
|
||||
disableMediaSpotlight: true,
|
||||
});
|
||||
const npub = !id?.startsWith(NostrPrefix.PublicKey) ? hexToBech32(NostrPrefix.PublicKey, id || undefined) : id;
|
||||
|
||||
|
@ -138,4 +138,17 @@ export abstract class EventExt {
|
||||
ret.pubKeys = Array.from(new Set(ev.tags.filter(a => a[0] === "p").map(a => a[1])));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign props if undefined
|
||||
*/
|
||||
static fixupEvent(e: NostrEvent) {
|
||||
e.tags ??= [];
|
||||
e.created_at ??= 0;
|
||||
e.content ??= "";
|
||||
e.id ??= "";
|
||||
e.kind ??= 0;
|
||||
e.pubkey ??= "";
|
||||
e.sig ??= "";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user