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,11 +26,14 @@ export default function Slideshow() {
>({}); >({});
const init = async () => { const init = async () => {
try {
// get requested collection id from localStorage // get requested collection id from localStorage
const requestedCollectionID = const requestedCollectionID =
window.localStorage.getItem('targetCollectionId'); window.localStorage.getItem('targetCollectionId');
const collection = await getCollection(Number(requestedCollectionID)); const collection = await getCollection(
Number(requestedCollectionID)
);
const files = await syncFiles('normal', [collection], () => {}); const files = await syncFiles('normal', [collection], () => {});
@ -39,6 +42,9 @@ export default function Slideshow() {
files.filter((file) => isFileEligibleForCast(file)) files.filter((file) => isFileEligibleForCast(file))
); );
} }
} catch {
router.push('/');
}
}; };
const isFileEligibleForCast = (file: EnteFile) => { const isFileEligibleForCast = (file: EnteFile) => {
@ -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(() => {