diff --git a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js
index 4d122997..9bfb74a0 100644
--- a/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js
+++ b/frontend/components/Viewing/Sections/Attachments/AttachmentRows.js
@@ -119,7 +119,6 @@ export default function AttachmentRows(properties) {
type: attachment.format.split('/').pop(),
status: 'downloading'
};
- console.log(item);
dispatch(downloadFiles([item]));
}
}}
@@ -138,10 +137,8 @@ export default function AttachmentRows(properties) {
{
- console.log("reached onclick");
const copy = [...attachments];
const deletedAttachment = copy.splice(key, 1);
- console.log(copy);
setAttachments(copy);
await getQueryResponse(
dispatch,
@@ -150,6 +147,7 @@ export default function AttachmentRows(properties) {
token,
true
);
+ window.location.reload();
}}
>
state.user.graphUri);
const attachments = useSelector(state => state.attachments.attachments);
+ const [refreshMembers, setRefreshMembers] = useState(false);
+
+ const handleSetRefreshMembers = (value) => {
+ setRefreshMembers(value);
+ };
+
useEffect(() => {
if (owner == undefined) {
//The attachments in the store should be reset, a new page has been loaded.
@@ -51,15 +57,31 @@ export default function Attachments(properties) {
}
}, [owner]);
+ useEffect(() => {
+ if (refreshMembers) {
+ // Fetch attachments again and update the state
+ getQueryResponse(dispatch, getAttachments, { uri: properties.uri }).then(
+ attachments => {
+ if (attachments.length > 0) {
+ dispatch(setAttachments(attachments));
+ }
+ // Reset refreshMembers to false after refreshing
+ setRefreshMembers(false);
+ }
+ );
+ window.location.reload();
+ }
+ }, [refreshMembers, dispatch, properties.uri]);
+
if (!owner) return ;
return (
);
}
diff --git a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js
index ec1c7342..1345f554 100644
--- a/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js
+++ b/frontend/components/Viewing/Sections/Attachments/UploadAttachments.js
@@ -187,6 +187,7 @@ export default function UploadAttachments(properties) {
const uriToUse = processedUriData.urlReplacedForBackend || processedUriData.original;
attachFromFile(selectedFiles, uriToUse).then(() => {
dispatch(setUploadStatus(''));
+ properties.setRefreshMembers(true);
});
//Query all the attachments so the store can be updated.
@@ -287,7 +288,9 @@ export default function UploadAttachments(properties) {
uri: uriToUse
};
- attachFromURL(attachment);
+ attachFromURL(attachment).then(() => {
+ properties.setRefreshMembers(true); // Ensure refresh after URL attachment
+ });
});
const convertedUrl = uri.slice(
@@ -306,6 +309,7 @@ export default function UploadAttachments(properties) {
dispatch(
setAttachments([...properties.attachments, newAttachment])
);
+ properties.setRefreshMembers(true);
//Resets all the values to their default.
setSelectedOption('Attachment type...');