Przeglądaj źródła

added updated collection not empty check

Abhinav-grd 4 lat temu
rodzic
commit
2c0ba89c33
1 zmienionych plików z 7 dodań i 5 usunięć
  1. 7 5
      src/pages/gallery/index.tsx

+ 7 - 5
src/pages/gallery/index.tsx

@@ -132,7 +132,7 @@ export default function Gallery(props) {
     useEffect(() => {
     useEffect(() => {
         const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
         const key = getKey(SESSION_KEYS.ENCRYPTION_KEY);
         const token = getToken();
         const token = getToken();
-        if (!key && token) {
+        if (!key || !token) {
             router.push('/');
             router.push('/');
         }
         }
         const main = async () => {
         const main = async () => {
@@ -143,10 +143,12 @@ export default function Gallery(props) {
             const collections = await getLocalCollections();
             const collections = await getLocalCollections();
             const collectionLatestFile = await getCollectionLatestFile(collections, token);
             const collectionLatestFile = await getCollectionLatestFile(collections, token);
             const favItemIds = await getFavItemIds(data);
             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);
             setProgress(100);
         };
         };
         main();
         main();