diff --git a/src/components/compose/Status.tsx b/src/components/compose/Status.tsx index 5834d513..65bd45a9 100644 --- a/src/components/compose/Status.tsx +++ b/src/components/compose/Status.tsx @@ -17,6 +17,7 @@ type Props = { } type FormValue = { + spoiler: string status: string attachments?: Array nsfw?: boolean @@ -37,11 +38,13 @@ type CustomEmoji = { const Status: React.FC = props => { const [formValue, setFormValue] = useState({ + spoiler: '', status: '' }) const [customEmojis, setCustomEmojis] = useState>([]) const [loading, setLoading] = useState(false) const [visibility, setVisibility] = useState<'public' | 'unlisted' | 'private' | 'direct'>('public') + const [cw, setCW] = useState(false) const formRef = useRef() const statusRef = useRef() @@ -80,7 +83,7 @@ const Status: React.FC = props => { useEffect(() => { if (props.in_reply_to) { - setFormValue({ status: `@${props.in_reply_to.account.acct} ` }) + setFormValue({ spoiler: '', status: `@${props.in_reply_to.account.acct} ` }) setVisibility(props.in_reply_to.visibility) } }, [props.in_reply_to]) @@ -118,6 +121,11 @@ const Status: React.FC = props => { sensitive: formValue.nsfw }) } + if (formValue.spoiler.length > 0) { + options = Object.assign({}, options, { + spoiler_text: formValue.spoiler + }) + } await props.client.postStatus(formValue.status, options) clear() } catch { @@ -130,6 +138,7 @@ const Status: React.FC = props => { const clear = () => { setFormValue({ + spoiler: '', status: '' }) if (props.onClose) { @@ -238,9 +247,15 @@ const Status: React.FC = props => { return (
+ {cw && ( + + + + )} + {/** @ts-ignore **/} - + }> + {formValue.attachments?.length > 0 && (