client: fix uploading files when no files are present

This commit is contained in:
Max Leiter 2022-03-21 19:14:40 -07:00
parent c1dcfb6a58
commit 266848e6b2
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA

View file

@ -88,7 +88,7 @@ const Post = () => {
const uploadDocs = useCallback((files: DocumentType[]) => { const uploadDocs = useCallback((files: DocumentType[]) => {
// if no title is set and the only document is empty, // if no title is set and the only document is empty,
const isFirstDocEmpty = docs.length <= 1 && docs[0].title === '' && docs[0].content === '' const isFirstDocEmpty = docs.length <= 1 && (docs.length ? docs[0].title === '' : true)
const shouldSetTitle = !title && isFirstDocEmpty const shouldSetTitle = !title && isFirstDocEmpty
if (shouldSetTitle) { if (shouldSetTitle) {
if (files.length === 1) { if (files.length === 1) {