mirror of
https://github.com/hoornet/vega.git
synced 2026-05-07 04:39:12 -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:
@@ -1,8 +1,46 @@
|
||||
import { useState } from "react";
|
||||
import { useUserStore } from "../../stores/user";
|
||||
import { useLightningStore } from "../../stores/lightning";
|
||||
import { useMuteStore } from "../../stores/mute";
|
||||
import { isValidNwcUri } from "../../lib/lightning/nwc";
|
||||
import { getNDK, getStoredRelayUrls, addRelay, removeRelay } from "../../lib/nostr";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
|
||||
function MutedRow({ pubkey, onUnmute }: { pubkey: string; onUnmute: () => void }) {
|
||||
const profile = useProfile(pubkey);
|
||||
const name = profile?.displayName || profile?.name || pubkey.slice(0, 12) + "…";
|
||||
return (
|
||||
<div className="flex items-center gap-3 px-3 py-2 border border-border text-[12px] group">
|
||||
{profile?.picture && (
|
||||
<img src={profile.picture} alt="" className="w-5 h-5 rounded-sm object-cover shrink-0" />
|
||||
)}
|
||||
<span className="text-text truncate flex-1">{name}</span>
|
||||
<button
|
||||
onClick={onUnmute}
|
||||
className="text-text-dim hover:text-accent text-[10px] opacity-0 group-hover:opacity-100 transition-opacity shrink-0"
|
||||
>
|
||||
unmute
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MuteSection() {
|
||||
const { mutedPubkeys, unmute } = useMuteStore();
|
||||
if (mutedPubkeys.length === 0) return null;
|
||||
return (
|
||||
<section>
|
||||
<h2 className="text-text text-[11px] font-medium uppercase tracking-widest mb-2 text-text-dim">
|
||||
Muted accounts ({mutedPubkeys.length})
|
||||
</h2>
|
||||
<div className="space-y-1">
|
||||
{mutedPubkeys.map((pk) => (
|
||||
<MutedRow key={pk} pubkey={pk} onUnmute={() => unmute(pk)} />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function RelayRow({ url, onRemove }: { url: string; onRemove: () => void }) {
|
||||
const ndk = getNDK();
|
||||
@@ -203,6 +241,7 @@ export function SettingsView() {
|
||||
<WalletSection />
|
||||
<RelaySection />
|
||||
<IdentitySection />
|
||||
<MuteSection />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user