feat: add more buttons to reply
This commit is contained in:
parent
760f4bcccb
commit
6ffa180812
4 changed files with 36 additions and 47 deletions
|
|
@ -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} />
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue