#10
This commit is contained in:
Zhiyuan Zheng 2021-02-08 00:23:32 +01:00
parent dd4234199b
commit 01d4e6a5b9
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
1 changed files with 19 additions and 7 deletions

View File

@ -224,6 +224,24 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
[composeState]
)
const dispatch = useDispatch()
const headerRightDisabled = useMemo(() => {
if (totalTextCount > maxTootChars) {
return true
}
if (
composeState.attachments.uploads.filter(upload => upload.uploading)
.length > 0
) {
return true
}
if (
composeState.attachments.uploads.length === 0 &&
composeState.text.raw.length === 0
) {
return true
}
return false
}, [totalTextCount, composeState.attachments.uploads, composeState.text.raw])
const headerRight = useCallback(
() => (
<HeaderRight
@ -270,13 +288,7 @@ const ScreenCompose: React.FC<ScreenComposeProp> = ({
})
}}
loading={composeState.posting}
disabled={
composeState.text.raw.length < 1 ||
totalTextCount > maxTootChars ||
(composeState.attachments.uploads.length > 0 &&
composeState.attachments.uploads.filter(upload => upload.uploading)
.length > 0)
}
disabled={headerRightDisabled}
/>
),
[totalTextCount, composeState]