Skip to content

Commit 32f50ac

Browse files
committed
feat(helper): remove previousPage and nextPage (#6565)
These functions are redundant with the setPage and setQueryParameter/s/setState functions and aren't used in InstantSearch BREAKING CHANGE: remove usage of helper.previousPage, helper.nextPage and use setPage, setState or setQueryParameter instead
1 parent 3e9df7f commit 32f50ac

File tree

4 files changed

+1
-69
lines changed

4 files changed

+1
-69
lines changed

packages/algoliasearch-helper/documentation-src/content/reference.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ Finally, you can retrieve if there is an on-going search with `hasPendingRequest
6262

6363
{{> jsdoc jsdoc/helper/setPage}}
6464

65-
{{> jsdoc jsdoc/helper/nextPage}}
66-
67-
{{> jsdoc jsdoc/helper/previousPage}}
68-
6965
{{> jsdoc jsdoc/helper/getPage}}
7066

7167
### Query parameters

packages/algoliasearch-helper/index.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ declare namespace algoliasearchHelper {
284284
toggleFacetExclusion(facet: string, value: string): this;
285285
toggleFacetRefinement(facet: string, value: string): this;
286286
toggleTag(tag: string): this;
287-
nextPage(): this;
288-
previousPage(): this;
289287
setPage(page: number): this;
290288
setQueryParameter<SearchParameter extends keyof PlainSearchParameters>(
291289
parameter: SearchParameter,

packages/algoliasearch-helper/src/algoliasearch.helper.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -989,34 +989,6 @@ AlgoliaSearchHelper.prototype.toggleTag = function (tag) {
989989
return this;
990990
};
991991

992-
/**
993-
* Increments the page number by one.
994-
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
995-
* @fires change
996-
* @chainable
997-
* @example
998-
* helper.setPage(0).nextPage().getPage();
999-
* // returns 1
1000-
*/
1001-
AlgoliaSearchHelper.prototype.nextPage = function () {
1002-
var page = this.state.page || 0;
1003-
return this.setPage(page + 1);
1004-
};
1005-
1006-
/**
1007-
* Decrements the page number by one.
1008-
* @fires change
1009-
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
1010-
* @chainable
1011-
* @example
1012-
* helper.setPage(1).previousPage().getPage();
1013-
* // returns 0
1014-
*/
1015-
AlgoliaSearchHelper.prototype.previousPage = function () {
1016-
var page = this.state.page || 0;
1017-
return this.setPage(page - 1);
1018-
};
1019-
1020992
/**
1021993
* Updates the current page.
1022994
* @function

packages/algoliasearch-helper/test/spec/algoliasearch.helper/pages.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var algoliasearchHelper = require('../../../index');
44

55
var fakeClient = {};
66

7-
test('setChange should change the current page', function () {
7+
test('setPage should change the current page', function () {
88
var helper = algoliasearchHelper(fakeClient, null, null);
99

1010
expect(helper.getPage()).toBeUndefined();
@@ -14,40 +14,6 @@ test('setChange should change the current page', function () {
1414
expect(helper.getPage()).toBe(3);
1515
});
1616

17-
test('nextPage should increment the page by one', function () {
18-
var helper = algoliasearchHelper(fakeClient, null, null);
19-
20-
expect(helper.getPage()).toBeUndefined();
21-
22-
helper.nextPage();
23-
helper.nextPage();
24-
helper.nextPage();
25-
26-
expect(helper.getPage()).toBe(3);
27-
});
28-
29-
test('previousPage should decrement the current page by one', function () {
30-
var helper = algoliasearchHelper(fakeClient, null, null);
31-
32-
expect(helper.getPage()).toBeUndefined();
33-
34-
helper.setPage(3);
35-
36-
expect(helper.getPage()).toBe(3);
37-
38-
helper.previousPage();
39-
40-
expect(helper.getPage()).toBe(2);
41-
});
42-
43-
test('previousPage should throw an error without a current page', function () {
44-
var helper = algoliasearchHelper(fakeClient, null, null);
45-
46-
expect(function () {
47-
helper.previousPage();
48-
}).toThrow('Page requested below 0.');
49-
});
50-
5117
test('pages should be reset if the mutation might change the number of pages', function () {
5218
var helper = algoliasearchHelper(fakeClient, '', {
5319
facets: ['facet1', 'f2'],

0 commit comments

Comments
 (0)