fix: loop through all search results pages
This commit is contained in:
committed by
Anton Shepilov
parent
e1d48daba5
commit
c1bc0c34f7
@@ -1626,6 +1626,7 @@ export class DocumentsService {
|
|||||||
? Pagination.fromPaginable(options.pagination)
|
? Pagination.fromPaginable(options.pagination)
|
||||||
: new Pagination();
|
: new Pagination();
|
||||||
let resultType: string | null = null; // Step 1: Declare before loop
|
let resultType: string | null = null; // Step 1: Declare before loop
|
||||||
|
const resultPageSize = parseInt(options.pagination?.limitStr || "100");
|
||||||
|
|
||||||
// loop through all pages until we get results
|
// loop through all pages until we get results
|
||||||
do {
|
do {
|
||||||
@@ -1685,7 +1686,7 @@ export class DocumentsService {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this flag is on, the access permissions were checked inside the database
|
// Check access permissions
|
||||||
if (!options.onlyDirectlyShared) {
|
if (!options.onlyDirectlyShared) {
|
||||||
filteredResult = await this.filter(filteredResult, async item => {
|
filteredResult = await this.filter(filteredResult, async item => {
|
||||||
try {
|
try {
|
||||||
@@ -1708,7 +1709,7 @@ export class DocumentsService {
|
|||||||
|
|
||||||
allResults.push(...filteredResult);
|
allResults.push(...filteredResult);
|
||||||
nextPage = result.nextPage ? Pagination.fromPaginable(result.nextPage) : undefined;
|
nextPage = result.nextPage ? Pagination.fromPaginable(result.nextPage) : undefined;
|
||||||
} while (allResults.length === 0 && nextPage?.page_token); // Continue only if results are empty and there's a next page.
|
} while (allResults.length !== resultPageSize && nextPage?.page_token); // Continue only if results are empty and there's a next page.
|
||||||
|
|
||||||
return new ListResult(resultType, allResults, nextPage);
|
return new ListResult(resultType, allResults, nextPage);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user