From aafdecdf138641c2abf3aeae389841ce8d994aac Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 31 Jan 2021 17:14:02 +0530 Subject: [PATCH] added collectionUpdateTime localForage to fetchcollection after last update --- src/services/collectionService.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/collectionService.ts b/src/services/collectionService.ts index 29b3b78f1..e2d6b34df 100644 --- a/src/services/collectionService.ts +++ b/src/services/collectionService.ts @@ -102,9 +102,11 @@ const getCollections = async ( }; export const fetchCollections = async (token: string, key: string) => { - const collections = await getCollections(token, '0', key); - const favCollection = collections.filter(collection => collection.type === CollectionType.favorites); + const collectionUpdateTime = await localForage.getItem('collection-update-time') as string; + const collections = await getCollections(token, collectionUpdateTime ?? '0', key); + const favCollection = await localForage.getItem('fav-collection') as collection[] ?? collections.filter(collection => collection.type === CollectionType.favorites); await localForage.setItem('fav-collection', favCollection); + await localForage.setItem('collection-update-time', Date.now() * 1000); return collections; };