diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 76fa368a5..1863bd78d 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -110,27 +110,30 @@ export default function Gallery(props) { useEffect(() => { const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); - const token = getData(LS_KEYS.USER).token; if (!key) { router.push('/'); } const main = async () => { setLoading(true); - const encryptionKey = await getActualKey(); - const collections = await fetchCollections(token, encryptionKey); - const data = await fetchData(token, collections); - const collectionLatestFile = await getCollectionLatestFile(collections, data); - const favItemIds = await getFavItemIds(data); - setCollections(collections); - setData(data); - setCollectionLatestFile(collectionLatestFile); - setFavItemIds(favItemIds); + await syncWithRemote(); setLoading(false); }; main(); props.setUploadButtonView(true); - }, [reload]); + }, []); + const syncWithRemote = async () => { + const token = getData(LS_KEYS.USER).token; + const encryptionKey = await getActualKey(); + const collections = await fetchCollections(token, encryptionKey); + const data = await fetchData(token, collections); + const collectionLatestFile = await getCollectionLatestFile(collections, data); + const favItemIds = await getFavItemIds(data); + setCollections(collections); + setData(data); + setCollectionLatestFile(collectionLatestFile); + setFavItemIds(favItemIds); + } if (!data || loading) { return (