import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useRequireAuth} from '#/state/session'
import {useSession} from '#/state/session'
import {EventStopper} from '#/view/com/util/EventStopper'
import {useTheme} from '#/alf'
import {CloseQuote_Stroke2_Corner1_Rounded as Quote} from '#/components/icons/Quote'
import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost'
import * as Menu from '#/components/Menu'
import {
PostControlButton,
PostControlButtonIcon,
PostControlButtonText,
} from './PostControlButton'
import {useFormatPostStatCount} from './util'
interface Props {
isReposted: boolean
repostCount?: number
onRepost: () => void
onQuote: () => void
big?: boolean
embeddingDisabled: boolean
}
export const RepostButton = ({
isReposted,
repostCount,
onRepost,
onQuote,
big,
embeddingDisabled,
}: Props) => {
const t = useTheme()
const {_} = useLingui()
const {hasSession} = useSession()
const requireAuth = useRequireAuth()
const formatPostStatCount = useFormatPostStatCount()
return hasSession ? (
{({props}) => {
return (
{typeof repostCount !== 'undefined' && repostCount > 0 && (
{formatPostStatCount(repostCount)}
)}
)
}}
{isReposted
? _(msg`Undo repost`)
: _(msg({message: `Repost`, context: `action`}))}
{embeddingDisabled
? _(msg`Quote posts disabled`)
: _(msg`Quote post`)}
) : (
requireAuth(() => {})}
active={isReposted}
activeColor={t.palette.positive_600}
label={_(msg`Repost or quote post`)}
big={big}>
{typeof repostCount !== 'undefined' && repostCount > 0 && (
{formatPostStatCount(repostCount)}
)}
)
}