diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 87131ebfa..c40b6e1ae 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -132,7 +132,7 @@ export default function Gallery(props) { useEffect(() => { const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); const token = getToken(); - if (!key && token) { + if (!key || !token) { router.push('/'); } const main = async () => { @@ -143,10 +143,12 @@ export default function Gallery(props) { const collections = await getLocalCollections(); const collectionLatestFile = await getCollectionLatestFile(collections, token); const favItemIds = await getFavItemIds(data); - setCollections(collections); - setData(data); - setCollectionLatestFile(collectionLatestFile); - setFavItemIds(favItemIds); + if (updatedCollections.length > 0) { + setCollections(collections); + setData(data); + setCollectionLatestFile(collectionLatestFile); + setFavItemIds(favItemIds); + } setProgress(100); }; main();