partial support replaceable event

This commit is contained in:
Ren Amamiya
2023-09-16 16:06:01 +07:00
parent 11ad281d72
commit 1206486016
5 changed files with 144 additions and 102 deletions

View File

@@ -1,7 +1,7 @@
import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
import { writeText } from '@tauri-apps/api/clipboard';
import { nip19 } from 'nostr-tools';
import { EventPointer } from 'nostr-tools/lib/nip19';
import { AddressPointer, EventPointer } from 'nostr-tools/lib/nip19';
import { useRef, useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
@@ -27,7 +27,9 @@ export function ArticleNoteScreen() {
const { id } = useParams();
const { db } = useStorage();
const { status, data } = useEvent(id);
const naddr = id.startsWith('naddr') ? (nip19.decode(id).data as AddressPointer) : null;
const { status, data } = useEvent(id, naddr);
const [isCopy, setIsCopy] = useState(false);
@@ -103,15 +105,15 @@ export function ArticleNoteScreen() {
<ThreadUser pubkey={data.pubkey} time={data.created_at} />
<div className="mt-2">{renderKind(data)}</div>
<div>
<NoteActions id={id} pubkey={data.pubkey} extraButtons={false} />
<NoteStats id={id} />
<NoteActions id={data.id} pubkey={data.pubkey} extraButtons={false} />
<NoteStats id={data.id} />
</div>
</div>
</div>
)}
<div ref={replyRef} className="px-3">
<NoteReplyForm id={id} pubkey={db.account.pubkey} />
<RepliesList id={id} />
<NoteReplyForm id={data?.id} pubkey={db.account.pubkey} />
<RepliesList id={data?.id} />
</div>
</div>
<div className="col-span-1" />