From 37bb67ea21dce54a7d4d6440e12173aa46f781c4 Mon Sep 17 00:00:00 2001 From: abhinav-grd Date: Fri, 10 Sep 2021 09:11:38 +0530 Subject: [PATCH] remove deleted collection from local --- src/pages/gallery/index.tsx | 2 ++ src/services/collectionService.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index e4f07fe3e..e0c898cc2 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -23,6 +23,7 @@ import { getFavItemIds, getLocalCollections, getNonEmptyCollections, + setLocalCollection, } from 'services/collectionService'; import constants from 'utils/strings/constants'; import billingService from 'services/billingService'; @@ -258,6 +259,7 @@ export default function Gallery() { collectionFilesCount.set(id, files.length); } setCollections(nonEmptyCollections); + setLocalCollection(nonEmptyCollections); setCollectionsAndTheirLatestFile(collectionsAndTheirLatestFile); setCollectionFilesCount(collectionFilesCount); const favItemIds = await getFavItemIds(files); diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index a07ff5669..d5f02d7c7 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -184,6 +184,10 @@ export const syncCollections = async () => { return collections; }; +export const setLocalCollection = async (collections: Collection[]) => { + await localForage.setItem(COLLECTIONS, collections); +}; + export const getCollectionsAndTheirLatestFile = ( collections: Collection[], files: File[]