feat: add more buttons to reply
This commit is contained in:
parent
760f4bcccb
commit
6ffa180812
4 changed files with 36 additions and 47 deletions
|
|
@ -11,11 +11,9 @@ import { formatCount } from './utils'
|
|||
|
||||
export default function LikeButton({
|
||||
event,
|
||||
variant = 'normal',
|
||||
canFetch = false
|
||||
}: {
|
||||
event: Event
|
||||
variant?: 'normal' | 'reply'
|
||||
canFetch?: boolean
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
|
|
@ -70,8 +68,7 @@ export default function LikeButton({
|
|||
return (
|
||||
<button
|
||||
className={cn(
|
||||
'flex items-center enabled:hover:text-red-400',
|
||||
variant === 'normal' ? 'gap-1' : 'flex-col',
|
||||
'flex items-center enabled:hover:text-red-400 gap-1',
|
||||
hasLiked ? 'text-red-400' : 'text-muted-foreground'
|
||||
)}
|
||||
onClick={like}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,20 @@ import { useTranslation } from 'react-i18next'
|
|||
import PostEditor from '../PostEditor'
|
||||
import { formatCount } from './utils'
|
||||
|
||||
export default function ReplyButton({ event }: { event: Event }) {
|
||||
export default function ReplyButton({
|
||||
event,
|
||||
variant = 'note'
|
||||
}: {
|
||||
event: Event
|
||||
variant?: 'note' | 'reply'
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const { checkLogin } = useNostr()
|
||||
const { noteStatsMap } = useNoteStats()
|
||||
const { replyCount } = useMemo(() => noteStatsMap.get(event.id) ?? {}, [noteStatsMap, event.id])
|
||||
const { replyCount } = useMemo(
|
||||
() => (variant === 'reply' ? {} : (noteStatsMap.get(event.id) ?? {})),
|
||||
[noteStatsMap, event.id, variant]
|
||||
)
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
return (
|
||||
|
|
@ -27,7 +36,9 @@ export default function ReplyButton({ event }: { event: Event }) {
|
|||
title={t('Reply')}
|
||||
>
|
||||
<MessageCircle size={16} />
|
||||
{!!replyCount && <div className="text-sm">{formatCount(replyCount)}</div>}
|
||||
{variant !== 'reply' && !!replyCount && (
|
||||
<div className="text-sm">{formatCount(replyCount)}</div>
|
||||
)}
|
||||
</button>
|
||||
<PostEditor parentEvent={event} open={open} setOpen={setOpen} />
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -8,16 +8,18 @@ import RepostButton from './RepostButton'
|
|||
export default function NoteStats({
|
||||
event,
|
||||
className,
|
||||
fetchIfNotExisting = false
|
||||
fetchIfNotExisting = false,
|
||||
variant = 'note'
|
||||
}: {
|
||||
event: Event
|
||||
className?: string
|
||||
fetchIfNotExisting?: boolean
|
||||
variant?: 'note' | 'reply'
|
||||
}) {
|
||||
return (
|
||||
<div className={cn('flex justify-between', className)}>
|
||||
<div className="flex gap-4 h-4 items-center" onClick={(e) => e.stopPropagation()}>
|
||||
<ReplyButton event={event} />
|
||||
<div className="flex gap-5 h-4 items-center" onClick={(e) => e.stopPropagation()}>
|
||||
<ReplyButton event={event} variant={variant} />
|
||||
<RepostButton event={event} canFetch={fetchIfNotExisting} />
|
||||
<LikeButton event={event} canFetch={fetchIfNotExisting} />
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue