Harvest valuable features from external/ reference repos, adapted to each product's stack and wired in; all products typecheck clean. - gitgram-web (5): clickable @mention/#hashtag linkify in rendered content (munia), + feed/notification/accessibility patterns; install @testing-library/dom - gitgram-backend (3): feed thread dedup + muted-thread removal (bluesky), GitHub star/follow write-back via OAuth (gh-social) - gitgram-mobile (4): double-tap-to-like + heart bounce (proximity), haptics layer (bluesky useHaptics), + gesture/feed UX - aitm-api (4): beads ready/dependency-DAG endpoints + atomic claim (beads) - aitm-mcp (6): beads_ready work-queue tool, context-efficient projections, transport arg aliasing (context7/pal-mcp/beads) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
'use client'
|
|
|
|
import { useCallback } from 'react'
|
|
import { useModeration } from '@/hooks/useModeration'
|
|
import { muteThread, unmuteThread } from '@/utils/moderation'
|
|
|
|
interface MuteThreadButtonProps {
|
|
postId: string
|
|
className?: string
|
|
}
|
|
|
|
/**
|
|
* Toggles a thread mute for a post. Muted threads are hidden from the feed by
|
|
* Feed.tsx (via utils/moderation). State is shared through useModeration so the
|
|
* label stays in sync everywhere.
|
|
*/
|
|
export default function MuteThreadButton({ postId, className = '' }: MuteThreadButtonProps) {
|
|
const moderation = useModeration()
|
|
const isMuted = moderation.mutedThreads.includes(postId)
|
|
|
|
const handleToggle = useCallback(() => {
|
|
if (isMuted) {
|
|
unmuteThread(postId)
|
|
} else {
|
|
muteThread(postId)
|
|
}
|
|
}, [isMuted, postId])
|
|
|
|
return (
|
|
<button
|
|
type="button"
|
|
onClick={handleToggle}
|
|
aria-pressed={isMuted}
|
|
className={`inline-flex items-center gap-2 rounded-lg border border-[var(--border)] px-3 py-2 text-sm font-medium text-[var(--foreground-secondary)] transition-colors hover:bg-[var(--surface-secondary)] hover:text-[var(--foreground)] ${className}`}
|
|
>
|
|
<svg className="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={2}>
|
|
{isMuted ? (
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M15.536 8.464a5 5 0 010 7.072M12 6.5L7 10H4a1 1 0 00-1 1v2a1 1 0 001 1h3l5 3.5v-11z"
|
|
/>
|
|
) : (
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
d="M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15zM17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"
|
|
/>
|
|
)}
|
|
</svg>
|
|
{isMuted ? 'Unmute thread' : 'Mute thread'}
|
|
</button>
|
|
)
|
|
}
|