feat: show quote note id when loading

feat: try load quote note from other relays
This commit is contained in:
kieran 2024-09-16 11:31:22 +01:00
parent 21e88b06cb
commit b0d2081b45
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
4 changed files with 65 additions and 6 deletions

View File

@ -22,7 +22,12 @@ export default function Copy({ text, maxSize = 32, className, showText, mask }:
: displayText;
return (
<div className={classNames("copy flex pointer g8 items-center", className)} onClick={() => copy(text)}>
<div
className={classNames("copy flex pointer g8 items-center", className)}
onClick={e => {
e.stopPropagation();
copy(text);
}}>
{(showText ?? true) && <span className="copy-body">{trimmed}</span>}
<span className="icon" style={{ color: copied ? "var(--success)" : "var(--highlight)" }}>
{copied ? <Icon name="check" size={14} /> : <Icon name="copy-solid" size={14} />}

View File

@ -1,8 +1,13 @@
import { NostrLink } from "@snort/system";
import { dedupe, sanitizeRelayUrl } from "@snort/shared";
import { NostrLink, NostrPrefix } from "@snort/system";
import { useEventFeed } from "@snort/system-react";
import { useState } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import AsyncButton from "@/Components/Button/AsyncButton";
import Copy from "@/Components/Copy/Copy";
import Note from "@/Components/Event/EventComponent";
import PageSpinner from "@/Components/PageSpinner";
import Spinner from "@/Components/Icons/Spinner";
const options = {
showFooter: false,
@ -10,11 +15,52 @@ const options = {
};
export default function NoteQuote({ link, depth }: { link: NostrLink; depth?: number }) {
const ev = useEventFeed(link);
const [tryLink, setLink] = useState<NostrLink>(link);
const [tryRelay, setTryRelay] = useState("");
const { formatMessage } = useIntl();
const ev = useEventFeed(tryLink);
if (!ev)
return (
<div className="note-quote flex items-center justify-center h-[110px]">
<PageSpinner />
<div className="note-quote flex flex-col gap-2">
<Spinner />
<div>
<FormattedMessage
defaultMessage="Looking for: {noteId}"
values={{
noteId: <Copy text={tryLink.encode()} />,
}}
/>
</div>
<div className="flex gap-2">
<input
type="text"
value={tryRelay}
onChange={e => setTryRelay(e.target.value)}
placeholder={formatMessage({ defaultMessage: "Try another relay" })}
/>
<AsyncButton
onClick={() => {
const u = sanitizeRelayUrl(tryRelay);
if (u) {
const relays = tryLink.relays ?? [];
relays.push(u);
setLink(
new NostrLink(
tryLink.type !== NostrPrefix.Address ? NostrPrefix.Event : NostrPrefix.Address,
tryLink.id,
tryLink.kind,
tryLink.author,
dedupe(relays),
tryLink.marker,
),
);
setTryRelay("");
}
}}>
<FormattedMessage defaultMessage="Add" />
</AsyncButton>
</div>
</div>
);
return <Note data={ev} className="note-quote" depth={(depth ?? 0) + 1} options={options} />;

View File

@ -297,6 +297,9 @@
"6OSOXl": {
"defaultMessage": "Reason: <i>{reason}</i>"
},
"6WWD34": {
"defaultMessage": "Looking for: {noteId}"
},
"6bgpn+": {
"defaultMessage": "Not all clients support this, you may still receive some zaps as if zap splits was not configured"
},
@ -1247,6 +1250,9 @@
"Yf3DwC": {
"defaultMessage": "Connect a wallet to send instant payments"
},
"YuoEb9": {
"defaultMessage": "Try another relay"
},
"Z4BMCZ": {
"defaultMessage": "Enter pairing phrase"
},

View File

@ -98,6 +98,7 @@
"6559gb": "New follow list length {length}",
"65BmHb": "Failed to proxy image from {host}, click here to load directly",
"6OSOXl": "Reason: <i>{reason}</i>",
"6WWD34": "Looking for: {noteId}",
"6bgpn+": "Not all clients support this, you may still receive some zaps as if zap splits was not configured",
"6ewQqw": "Likes ({n})",
"6k7xfM": "Trending notes",
@ -413,6 +414,7 @@
"YU7ZYp": "Public Chat",
"YXA3AH": "Enable reactions",
"Yf3DwC": "Connect a wallet to send instant payments",
"YuoEb9": "Try another relay",
"Z4BMCZ": "Enter pairing phrase",
"Z7kkeJ": "Delegated Event Signing",
"ZFe9tl": "Compose a note",