update collection time after all files fetched
This commit is contained in:
parent
f72ab9b418
commit
45fd07bc5f
2 changed files with 6 additions and 3 deletions
|
@ -117,13 +117,11 @@ export const fetchUpdatedCollections = async (token: string, key: string) => {
|
|||
latestCollectionsInstances.set(collection.id, collection);
|
||||
}
|
||||
});
|
||||
let collections = [], updationTime = 0;
|
||||
let collections = [];
|
||||
for (const [_, collection] of latestCollectionsInstances) {
|
||||
collections.push(collection);
|
||||
updationTime = Math.max(updationTime, collection.updationTime);
|
||||
}
|
||||
await localForage.setItem('fav-collection', favCollection);
|
||||
await localForage.setItem('collection-update-time', updationTime);
|
||||
await localForage.setItem('collections', collections);
|
||||
return updatedCollections;
|
||||
};
|
||||
|
|
|
@ -103,6 +103,11 @@ export const fetchFiles = async (
|
|||
for (let [collectionID, updationTime] of collectionUpdationTime) {
|
||||
await localForage.setItem(`${collectionID}-time`, updationTime);
|
||||
}
|
||||
let updationTime = await localForage.getItem('collection-update-time') as number;
|
||||
for (let collection of collections) {
|
||||
updationTime = Math.max(updationTime, collection.updationTime);
|
||||
}
|
||||
await localForage.setItem('collection-update-time', updationTime);
|
||||
return files;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue