|
@@ -76,7 +76,7 @@ export const fetchFiles = async (
|
|
collections: collection[]
|
|
collections: collection[]
|
|
) => {
|
|
) => {
|
|
let files = await localFiles();
|
|
let files = await localFiles();
|
|
- const fetchedFiles = await getFiles(collections, null, "100", token);
|
|
|
|
|
|
+ const fetchedFiles = await getFiles(collections, null, 100, token);
|
|
|
|
|
|
files.push(...fetchedFiles);
|
|
files.push(...fetchedFiles);
|
|
var latestFiles = new Map<string, file>();
|
|
var latestFiles = new Map<string, file>();
|
|
@@ -98,7 +98,7 @@ export const fetchFiles = async (
|
|
return files;
|
|
return files;
|
|
};
|
|
};
|
|
|
|
|
|
-export const getFiles = async (collections: collection[], sinceTime: string, limit: string, token: string): Promise<file[]> => {
|
|
|
|
|
|
+export const getFiles = async (collections: collection[], sinceTime: string, limit: number, token: string): Promise<file[]> => {
|
|
try {
|
|
try {
|
|
const worker = await new CryptoWorker();
|
|
const worker = await new CryptoWorker();
|
|
let promises: Promise<file>[] = [];
|
|
let promises: Promise<file>[] = [];
|
|
@@ -115,7 +115,7 @@ export const getFiles = async (collections: collection[], sinceTime: string, lim
|
|
resp = await HTTPService.get(`${ENDPOINT}/collections/diff`, {
|
|
resp = await HTTPService.get(`${ENDPOINT}/collections/diff`, {
|
|
collectionID: collection.id,
|
|
collectionID: collection.id,
|
|
sinceTime: time,
|
|
sinceTime: time,
|
|
- limit,
|
|
|
|
|
|
+ limit: limit.toString(),
|
|
},
|
|
},
|
|
{
|
|
{
|
|
'X-Auth-Token': token
|
|
'X-Auth-Token': token
|
|
@@ -138,7 +138,7 @@ export const getFiles = async (collections: collection[], sinceTime: string, lim
|
|
if (resp.data.diff.length) {
|
|
if (resp.data.diff.length) {
|
|
time = resp.data.diff.slice(-1)[0].updationTime.toString();
|
|
time = resp.data.diff.slice(-1)[0].updationTime.toString();
|
|
}
|
|
}
|
|
- } while (resp.data.diff.length);
|
|
|
|
|
|
+ } while (resp.data.diff.length === limit);
|
|
await localForage.setItem(`${collection.id}-time`, time);
|
|
await localForage.setItem(`${collection.id}-time`, time);
|
|
}
|
|
}
|
|
return Promise.all(promises);
|
|
return Promise.all(promises);
|