Skip to content

Commit

Permalink
Merge pull request #761 from SynBioHub/attachmentsfix
Browse files Browse the repository at this point in the history
made some changes for upload attachments, backend doesn't like it whe…
  • Loading branch information
ima-mervin authored Sep 18, 2024
2 parents 6df36fd + 84cdf46 commit 92f2f36
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<table className={styles.table}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/commitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5404d880804c953690dad2136246f625b9aaceca
c8d687e1e2b0a24ec2e3164ca6250a256f9ea980

0 comments on commit 92f2f36

Please sign in to comment.