diff --git a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js index 9bfb74a0..adc378b1 100644 --- a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js +++ b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js @@ -29,17 +29,19 @@ export default function AttachmentRows(properties) { const dispatch = useDispatch(); const token = useSelector(state => state.user.token); const [attachmentInfo, setStateAttachments] = useState(); - const [attachments, setAttachments] = useState(properties.attachments.map(attachment => ({ + + const [attachments, setAttachments] = useState((properties.attachments || []).map(attachment => ({ ...attachment, processedTopLevel: attachment.topLevel // Initialize with topLevel }))); + //There are attachments from the parent but they haven't been added to the state yet. - if (attachmentInfo === undefined && properties.attachments.length > 0) + if (attachmentInfo === undefined && properties.attachments && properties.attachments.length > 0) setStateAttachments(properties.attachments); //There are no attachments to get. - if (properties.attachments.length === 0) return null; + if (properties.attachments && properties.attachments.length === 0) return null; // useEffect(() => { // async function processAttachments() { diff --git a/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js b/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js index f07af3c8..67c3077f 100644 --- a/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js +++ b/frontend/components/Viewing/Sections/Attachments/AttachmentsTable.js @@ -8,8 +8,8 @@ import styles from '../../../../styles/view.module.css'; */ export default function AttachmentsTable(properties) { const header = createHeader(properties.headers); - - if (properties.attachments.length === 0 && !properties.owner) return null; + console.log(properties); + if (properties.attachments && properties.attachments.length === 0 && !properties.owner) return null; return ( diff --git a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js index 1345f554..934c89b8 100644 --- a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js +++ b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js @@ -193,7 +193,7 @@ export default function UploadAttachments(properties) { //Query all the attachments so the store can be updated. getQueryResponse(dispatch, getAttachments, { uri: properties.uri - }).then(allAttachments => { + }, token).then(allAttachments => { dispatch(setAttachments(allAttachments)); }); }); diff --git a/frontend/public/commitHash.txt b/frontend/public/commitHash.txt index 97f69a6a..921f76cc 100644 --- a/frontend/public/commitHash.txt +++ b/frontend/public/commitHash.txt @@ -1 +1 @@ -5404d880804c953690dad2136246f625b9aaceca \ No newline at end of file +c8d687e1e2b0a24ec2e3164ca6250a256f9ea980 \ No newline at end of file