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 () => {
// get requested collection id from localStorage
const requestedCollectionID =
window.localStorage.getItem('targetCollectionId');
try {
// get requested collection id from localStorage
const requestedCollectionID =
window.localStorage.getItem('targetCollectionId');
const collection = await getCollection(Number(requestedCollectionID));
const files = await syncFiles('normal', [collection], () => {});
if (requestedCollectionID) {
setCollectionFiles(
files.filter((file) => isFileEligibleForCast(file))
const collection = await getCollection(
Number(requestedCollectionID)
);
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();
useEffect(() => {
try {
init();
} catch (e) {
router.push('/');
}
init();
}, []);
useEffect(() => {