Skip to content

Commit 6a7a2fb

Browse files
steveohCopilot
andauthored
refactor: move download out of every render
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fabe5a9 commit 6a7a2fb

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/components/pageElements/Submissions.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@ const Submission = ({ item, dispatch }) => {
7272
const { label, submitted, id, status, geometry, attributes } = item;
7373
const submission = Date.parse(submitted);
7474

75-
try {
76-
getDownloadURL(ref(storage, attributes.ref)).then(setUrl);
77-
} catch {
78-
logEvent('download-submission-error', {
79-
document: item.key,
80-
});
81-
}
75+
useEffect(() => {
76+
if (attributes?.ref) {
77+
getDownloadURL(ref(storage, attributes.ref))
78+
.then(setUrl)
79+
.catch(() => {
80+
logEvent('download-submission-error', {
81+
document: item.key,
82+
});
83+
});
84+
}
85+
}, [attributes?.ref]);
8286

8387
console.log('submission', { status, label, attributes });
8488

0 commit comments

Comments
 (0)