mirror of
https://github.com/hoornet/vega.git
synced 2026-05-11 06:39:10 -07:00
Add mute/ignore user + anti-spam (roadmap #5, NIP-51)
- fetchMuteList / publishMuteList in nostr client (kind 10000) - mute store: mutedPubkeys persisted to localStorage + synced to relay; mute/unmute publish kind 10000 best-effort; fetchMuteList merges relay list with local mutes on login - fetchMuteList called after every login (nsec + pubkey) - Feed: muted pubkeys filtered from both Global and Following tabs - NoteCard: ⋯ context menu (appears on hover, hidden for own notes) with mute / unmute action; backdrop click closes menu - ProfileView: mute / unmute button in the action row (next to follow) - SettingsView: MuteSection lists muted accounts with name + avatar; hover to reveal unmute button; hidden when mute list is empty Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -274,6 +274,27 @@ export async function publishContactList(pubkeys: string[]): Promise<void> {
|
||||
await event.publish();
|
||||
}
|
||||
|
||||
export async function fetchMuteList(pubkey: string): Promise<string[]> {
|
||||
const instance = getNDK();
|
||||
const filter: NDKFilter = { kinds: [10000 as NDKKind], authors: [pubkey], limit: 1 };
|
||||
const events = await instance.fetchEvents(filter, {
|
||||
cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY,
|
||||
});
|
||||
if (events.size === 0) return [];
|
||||
const event = Array.from(events).sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0))[0];
|
||||
return event.tags.filter((t) => t[0] === "p" && t[1]).map((t) => t[1]);
|
||||
}
|
||||
|
||||
export async function publishMuteList(pubkeys: string[]): Promise<void> {
|
||||
const instance = getNDK();
|
||||
if (!instance.signer) return;
|
||||
const event = new NDKEvent(instance);
|
||||
event.kind = 10000 as NDKKind;
|
||||
event.content = "";
|
||||
event.tags = pubkeys.map((pk) => ["p", pk]);
|
||||
await event.publish();
|
||||
}
|
||||
|
||||
export async function fetchProfile(pubkey: string) {
|
||||
const instance = getNDK();
|
||||
const user = instance.getUser({ pubkey });
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { getNDK, connectToRelays, fetchGlobalFeed, fetchFollowFeed, fetchReplies, publishNote, publishArticle, publishProfile, publishReaction, publishReply, publishContactList, fetchReactionCount, fetchUserNotes, fetchProfile, getStoredRelayUrls, addRelay, removeRelay, searchNotes, searchUsers } from "./client";
|
||||
export { getNDK, connectToRelays, fetchGlobalFeed, fetchFollowFeed, fetchReplies, publishNote, publishArticle, publishProfile, publishReaction, publishReply, publishContactList, fetchReactionCount, fetchUserNotes, fetchProfile, fetchMuteList, publishMuteList, getStoredRelayUrls, addRelay, removeRelay, searchNotes, searchUsers } from "./client";
|
||||
|
||||
Reference in New Issue
Block a user