change collection id type to number
This commit is contained in:
parent
5c5a161999
commit
71af57409a
2 changed files with 11 additions and 9 deletions
|
@ -22,7 +22,7 @@ enum CollectionType {
|
|||
}
|
||||
|
||||
export interface collection {
|
||||
id: string;
|
||||
id: number;
|
||||
owner: user;
|
||||
key?: string;
|
||||
name?: string;
|
||||
|
@ -111,7 +111,7 @@ export const fetchUpdatedCollections = async (token: string, key: string) => {
|
|||
const favCollection = await localForage.getItem('fav-collection') as collection[] ?? updatedCollections.filter(collection => collection.type === CollectionType.favorites);
|
||||
const localCollections = await getLocalCollections();
|
||||
const allCollectionsInstances = [...localCollections, ...updatedCollections];
|
||||
var latestCollectionsInstances = new Map<string, collection>();
|
||||
var latestCollectionsInstances = new Map<number, collection>();
|
||||
allCollectionsInstances.forEach((collection) => {
|
||||
if (!latestCollectionsInstances.has(collection.id) || latestCollectionsInstances.get(collection.id).updationTime < collection.updationTime) {
|
||||
latestCollectionsInstances.set(collection.id, collection);
|
||||
|
@ -119,8 +119,9 @@ export const fetchUpdatedCollections = async (token: string, key: string) => {
|
|||
});
|
||||
let collections = [];
|
||||
for (const [_, collection] of latestCollectionsInstances) {
|
||||
if (!collection.isDeleted)
|
||||
if (!collection.isDeleted){
|
||||
collections.push(collection);
|
||||
}
|
||||
}
|
||||
await localForage.setItem('fav-collection', favCollection);
|
||||
await localForage.setItem('collections', collections);
|
||||
|
|
|
@ -76,16 +76,16 @@ export const fetchFiles = async (
|
|||
collections: collection[]
|
||||
) => {
|
||||
let files = await localFiles();
|
||||
const collectionUpdationTime = new Map<string, string>();
|
||||
const collectionUpdationTime = new Map<number, number>();
|
||||
let fetchedFiles = [];
|
||||
let deletedCollection = new Set<string>();
|
||||
let deletedCollection = new Set<number>();
|
||||
for (let collection of collections) {
|
||||
if (collection.isDeleted) {
|
||||
deletedCollection.add(collection.id);
|
||||
}
|
||||
const files = await getFiles(collection, null, 100, token);
|
||||
fetchedFiles.push(...files);
|
||||
collectionUpdationTime.set(collection.id, files.length > 0 ? files.slice(-1)[0].updationTime.toString() : "0");
|
||||
collectionUpdationTime.set(collection.id, files.length > 0 ? files.slice(-1)[0].updationTime : 0);
|
||||
}
|
||||
files.push(...fetchedFiles);
|
||||
var latestFiles = new Map<string, file>();
|
||||
|
@ -97,9 +97,10 @@ export const fetchFiles = async (
|
|||
});
|
||||
files = [];
|
||||
for (const [_, file] of latestFiles) {
|
||||
if (!(file.isDeleted || deletedCollection.has(file.collectionID.toString()))) {
|
||||
files.push(file);
|
||||
if (file.isDeleted || deletedCollection.has(file.collectionID)) {
|
||||
continue;
|
||||
}
|
||||
files.push(file);
|
||||
}
|
||||
files = files.sort(
|
||||
(a, b) => b.metadata.creationTime - a.metadata.creationTime
|
||||
|
@ -129,7 +130,7 @@ export const getFiles = async (collection: collection, sinceTime: string, limit:
|
|||
let resp;
|
||||
do {
|
||||
resp = await HTTPService.get(`${ENDPOINT}/collections/diff`, {
|
||||
collectionID: collection.id,
|
||||
collectionID: collection.id.toString(),
|
||||
sinceTime: time,
|
||||
limit: limit.toString(),
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue