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:
Jure
2026-03-10 18:23:30 +01:00
parent 926a7cbdae
commit 42fe32f584
8 changed files with 168 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
import { NDKEvent } from "@nostr-dev-kit/ndk";
import { useUIStore } from "../../stores/ui";
import { useUserStore } from "../../stores/user";
import { useMuteStore } from "../../stores/mute";
import { useProfile, invalidateProfileCache } from "../../hooks/useProfile";
import { fetchUserNotes, publishProfile } from "../../lib/nostr";
import { shortenPubkey } from "../../lib/utils";
@@ -116,6 +117,8 @@ export function ProfileView() {
const [showZap, setShowZap] = useState(false);
const isFollowing = follows.includes(pubkey);
const { mutedPubkeys, mute, unmute } = useMuteStore();
const isMuted = mutedPubkeys.includes(pubkey);
const handleFollowToggle = async () => {
setFollowPending(true);
@@ -185,6 +188,16 @@ export function ProfileView() {
>
{followPending ? "…" : isFollowing ? "unfollow" : "follow"}
</button>
<button
onClick={() => isMuted ? unmute(pubkey) : mute(pubkey)}
className={`text-[11px] px-3 py-1 border transition-colors ${
isMuted
? "border-danger/40 text-danger hover:bg-danger/5"
: "border-border text-text-dim hover:text-danger hover:border-danger/40"
}`}
>
{isMuted ? "unmute" : "mute"}
</button>
</div>
)}
</header>