added collectionUpdateTime localForage to fetchcollection after last update

This commit is contained in:
Abhinav-grd 2021-01-31 17:14:02 +05:30
parent 80c46796cf
commit aafdecdf13

View file

@ -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;
};