fix: switch try catch

This commit is contained in:
httpjamesm 2023-11-28 08:39:47 -05:00
parent ff37b482ad
commit 93c317393f
No known key found for this signature in database

View file

@ -26,18 +26,24 @@ export default function Slideshow() {
>({}); >({});
const init = async () => { const init = async () => {
// get requested collection id from localStorage try {
const requestedCollectionID = // get requested collection id from localStorage
window.localStorage.getItem('targetCollectionId'); const requestedCollectionID =
window.localStorage.getItem('targetCollectionId');
const collection = await getCollection(Number(requestedCollectionID)); const collection = await getCollection(
Number(requestedCollectionID)
const files = await syncFiles('normal', [collection], () => {});
if (requestedCollectionID) {
setCollectionFiles(
files.filter((file) => isFileEligibleForCast(file))
); );
const files = await syncFiles('normal', [collection], () => {});
if (requestedCollectionID) {
setCollectionFiles(
files.filter((file) => isFileEligibleForCast(file))
);
}
} catch {
router.push('/');
} }
}; };
@ -70,11 +76,7 @@ export default function Slideshow() {
const router = useRouter(); const router = useRouter();
useEffect(() => { useEffect(() => {
try { init();
init();
} catch (e) {
router.push('/');
}
}, []); }, []);
useEffect(() => { useEffect(() => {