Skip to content

Commit bdc6e75

Browse files
author
Shiranuit
authored
Merge pull request #711 from kuzzleio/bugfix-search-next-with-from
Fix bug where calling next on search with a from always return the same results
2 parents d247e95 + 88a50d0 commit bdc6e75

File tree

7 files changed

+46
-63
lines changed

7 files changed

+46
-63
lines changed

src/core/searchResult/SearchResultBase.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,11 @@ export class SearchResultBase<T> implements SearchResult<T> {
164164
}
165165

166166
return this._kuzzle
167-
.query(
168-
{
169-
...this._request,
170-
action: this._searchAction,
171-
from: this.fetched,
172-
},
173-
this._options
174-
)
167+
.query({
168+
...this._request,
169+
action: this._searchAction,
170+
from: this.fetched,
171+
})
175172
.then(({ result }) => this._buildNextSearchResult(result));
176173
}
177174

src/protocols/abstract/Realtime.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ export abstract class BaseProtocolRealtime extends KuzzleAbstractProtocol {
8383
this.retrying = true;
8484

8585
if (
86+
window !== null &&
8687
typeof window === "object" &&
87-
typeof window.navigator === "object" &&
88-
window.navigator.onLine === false
88+
typeof window!.navigator === "object" &&
89+
window!.navigator.onLine === false
8990
) {
90-
window.addEventListener(
91+
window!.addEventListener(
9192
"online",
9293
() => {
9394
this.retrying = false;

test/core/searchResult/document.test.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,15 @@ describe("DocumentSearchResult", () => {
332332
return searchResult.next().then((nextSearchResult) => {
333333
should(kuzzle.query)
334334
.be.calledOnce()
335-
.be.calledWith(
336-
{
337-
index: "index",
338-
collection: "collection",
339-
body: { query: { foo: "bar" } },
340-
controller: "document",
341-
action: "search",
342-
size: 2,
343-
from: 2,
344-
},
345-
options
346-
);
335+
.be.calledWith({
336+
index: "index",
337+
collection: "collection",
338+
body: { query: { foo: "bar" } },
339+
controller: "document",
340+
action: "search",
341+
size: 2,
342+
from: 2,
343+
});
347344
should(nextSearchResult).not.be.equal(searchResult);
348345
should(nextSearchResult).be.instanceOf(DocumentSearchResult);
349346
});

test/core/searchResult/profile.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,16 +352,13 @@ describe("ProfileSearchResult", () => {
352352
return searchResult.next().then((nextSearchResult) => {
353353
should(kuzzle.query)
354354
.be.calledOnce()
355-
.be.calledWith(
356-
{
357-
body: { query: { foo: "bar" } },
358-
controller: "security",
359-
action: "searchProfiles",
360-
size: 2,
361-
from: 2,
362-
},
363-
options
364-
);
355+
.be.calledWith({
356+
body: { query: { foo: "bar" } },
357+
controller: "security",
358+
action: "searchProfiles",
359+
size: 2,
360+
from: 2,
361+
});
365362
should(nextSearchResult).not.be.equal(searchResult);
366363
should(nextSearchResult).be.instanceOf(ProfileSearchResult);
367364
});

test/core/searchResult/role.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,13 @@ describe("RoleSearchResult", () => {
160160
return searchResult.next().then((nextSearchResult) => {
161161
should(kuzzle.query)
162162
.be.calledOnce()
163-
.be.calledWith(
164-
{
165-
body: { foo: "bar" },
166-
controller: "security",
167-
action: "searchRoles",
168-
size: 2,
169-
from: 2,
170-
},
171-
options
172-
);
163+
.be.calledWith({
164+
body: { foo: "bar" },
165+
controller: "security",
166+
action: "searchRoles",
167+
size: 2,
168+
from: 2,
169+
});
173170
should(nextSearchResult).not.be.equal(searchResult);
174171
should(nextSearchResult).be.instanceOf(RoleSearchResult);
175172
});

test/core/searchResult/specifications.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,13 @@ describe("SpecificationsSearchResult", () => {
331331
return searchResult.next().then((nextSearchResult) => {
332332
should(kuzzle.query)
333333
.be.calledOnce()
334-
.be.calledWith(
335-
{
336-
body: { query: { foo: "bar" } },
337-
controller: "collection",
338-
action: "searchSpecifications",
339-
size: 2,
340-
from: 2,
341-
},
342-
options
343-
);
334+
.be.calledWith({
335+
body: { query: { foo: "bar" } },
336+
controller: "collection",
337+
action: "searchSpecifications",
338+
size: 2,
339+
from: 2,
340+
});
344341
should(nextSearchResult).not.be.equal(searchResult);
345342
should(nextSearchResult).be.instanceOf(SpecificationsSearchResult);
346343
});

test/core/searchResult/user.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,13 @@ describe("UserSearchResult", () => {
392392
return searchResult.next().then((nextSearchResult) => {
393393
should(kuzzle.query)
394394
.be.calledOnce()
395-
.be.calledWith(
396-
{
397-
body: { query: { foo: "bar" } },
398-
controller: "security",
399-
action: "searchUsers",
400-
size: 2,
401-
from: 2,
402-
},
403-
options
404-
);
395+
.be.calledWith({
396+
body: { query: { foo: "bar" } },
397+
controller: "security",
398+
action: "searchUsers",
399+
size: 2,
400+
from: 2,
401+
});
405402
should(nextSearchResult).not.be.equal(searchResult);
406403
should(nextSearchResult).be.instanceOf(UserSearchResult);
407404
});

0 commit comments

Comments
 (0)