mirror of
https://github.com/hoornet/vega.git
synced 2026-05-10 14:19:12 -07:00
Add Quote / Repost (NIP-18, roadmap #6)
- publishRepost: kind 6 event with stringified original event as content and ["e", id, "", "mention"] + ["p", pubkey] tags - publishQuote: kind 1 note with user's text + appended nostr:nevent1... reference and ["q", id] + ["p", pubkey] tags - QuoteModal: compose modal with live quoted-note preview (avatar, name, truncated content); Ctrl+Enter to post, Escape to close - NoteCard: "repost" (one-click, shows "reposted ✓") and "quote" (opens QuoteModal) added to the actions row alongside reply/like/zap Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import NDK, { NDKEvent, NDKFilter, NDKKind, NDKRelay, NDKSubscriptionCacheUsage } from "@nostr-dev-kit/ndk";
|
||||
import NDK, { NDKEvent, NDKFilter, NDKKind, NDKRelay, NDKSubscriptionCacheUsage, nip19 } from "@nostr-dev-kit/ndk";
|
||||
|
||||
const RELAY_STORAGE_KEY = "wrystr_relays";
|
||||
|
||||
@@ -146,6 +146,37 @@ export async function publishArticle(opts: {
|
||||
await event.publish();
|
||||
}
|
||||
|
||||
export async function publishRepost(event: NDKEvent): Promise<void> {
|
||||
const instance = getNDK();
|
||||
if (!instance.signer) throw new Error("Not logged in");
|
||||
|
||||
const repost = new NDKEvent(instance);
|
||||
repost.kind = NDKKind.Repost; // kind 6
|
||||
repost.content = JSON.stringify(event.rawEvent());
|
||||
repost.tags = [
|
||||
["e", event.id!, "", "mention"],
|
||||
["p", event.pubkey],
|
||||
];
|
||||
await repost.publish();
|
||||
}
|
||||
|
||||
export async function publishQuote(content: string, quotedEvent: NDKEvent): Promise<void> {
|
||||
const instance = getNDK();
|
||||
if (!instance.signer) throw new Error("Not logged in");
|
||||
|
||||
const nevent = nip19.neventEncode({ id: quotedEvent.id!, author: quotedEvent.pubkey });
|
||||
const fullContent = content.trim() + "\n\nnostr:" + nevent;
|
||||
|
||||
const note = new NDKEvent(instance);
|
||||
note.kind = NDKKind.Text;
|
||||
note.content = fullContent;
|
||||
note.tags = [
|
||||
["q", quotedEvent.id!, ""],
|
||||
["p", quotedEvent.pubkey],
|
||||
];
|
||||
await note.publish();
|
||||
}
|
||||
|
||||
export async function publishReaction(eventId: string, eventPubkey: string, reaction = "+"): Promise<void> {
|
||||
const instance = getNDK();
|
||||
if (!instance.signer) throw new Error("Not logged in");
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { getNDK, connectToRelays, fetchGlobalFeed, fetchFollowFeed, fetchReplies, publishNote, publishArticle, publishProfile, publishReaction, publishReply, publishContactList, fetchReactionCount, fetchUserNotes, fetchProfile, fetchMuteList, publishMuteList, getStoredRelayUrls, addRelay, removeRelay, searchNotes, searchUsers } from "./client";
|
||||
export { getNDK, connectToRelays, fetchGlobalFeed, fetchFollowFeed, fetchReplies, publishNote, publishArticle, publishProfile, publishReaction, publishRepost, publishQuote, publishReply, publishContactList, fetchReactionCount, fetchUserNotes, fetchProfile, fetchMuteList, publishMuteList, getStoredRelayUrls, addRelay, removeRelay, searchNotes, searchUsers } from "./client";
|
||||
|
||||
Reference in New Issue
Block a user