Skip to content

Commit

Permalink
fix respect catalog configuration (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubomír Bucek committed Nov 11, 2019
1 parent 6e1cbaf commit 1501e1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export class OpenSearchPaginator {
* (the default) or the `startPage`.
* @param {int} [options.totalResults=undefined] Total results on all pages. Can be set from
* previous searches for optimized `searchFirstRecords`
* @param {int} [options.serverItemsPerPage=undefined] Server allowed page size. Can be set from
* previous searches for optimized `searchFirstRecords`
* @param {int} [options.baseOffset=0] The base index offset to apply. This option
* is useful when resuming a consecutive search.
* @param {int} [options.maxUrlLength=undefined] The maximum URL length. Forwarded to
Expand All @@ -90,7 +88,6 @@ export class OpenSearchPaginator {
preferStartIndex = true,
baseOffset = 0,
totalResults = undefined,
serverItemsPerPage = undefined,
...searchOptions
} = options;
this._url = url;
Expand All @@ -100,7 +97,6 @@ export class OpenSearchPaginator {
this._preferStartIndex = preferStartIndex;
this._baseOffset = baseOffset;
this._totalResults = totalResults;
this._serverItemsPerPage = serverItemsPerPage;
this._searchOptions = searchOptions;
}

Expand Down Expand Up @@ -241,11 +237,11 @@ export class OpenSearchPaginator {
const emitter = new PagedSearchProgressEmitter();
let request = null;
let startPageIndex = null;
if (this._serverItemsPerPage && this._totalResults && typeof maxCount !== 'undefined' && maxCount !== 0) {
if (this._preferredItemsPerPage && this._totalResults && typeof maxCount !== 'undefined' && maxCount !== 0) {
// if paginator created based on known values - continue search
// do not request first page to get values
request = Promise.resolve({
itemsPerPage: this._serverItemsPerPage,
itemsPerPage: this._preferredItemsPerPage,
records: [],
totalResults: this._totalResults,
startIndex: this._baseOffset,
Expand Down
2 changes: 1 addition & 1 deletion test/paginator.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('OpenSearchPaginator', () => {

it('shall correctly emit "page" and "success" events when paginator is given catalog information from previous run to continue', (done) => {
const paginatorSettings = {
serverItemsPerPage: 25,
preferredItemsPerPage: 25,
totalResults: 51,
baseOffset: 25,
};
Expand Down

0 comments on commit 1501e1b

Please sign in to comment.