Skip to content

Commit

Permalink
Merge pull request #1001 from searchspring/develop
Browse files Browse the repository at this point in the history
Release 0.51.2
  • Loading branch information
korgon authored Feb 12, 2024
2 parents b29a093 + e97a1bb commit 51239fd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/snap-client/src/Client/apis/Legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class LegacyAPI extends API {
//remove pageLoadId from cache key query params
const cacheParameters = { ...queryParameters };
delete cacheParameters.pageLoadId;
delete cacheParameters.domain;

const legacyResponse = await this.request(
{
Expand Down
5 changes: 5 additions & 0 deletions packages/snap-controller/src/Search/SearchController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ describe('Search Controller', () => {

const { pageSize } = controller.store.pagination;
expect(searchfn).toHaveBeenCalledTimes(page);

expect(searchfn).toHaveBeenNthCalledWith(1, expect.objectContaining({ pagination: {} }));
expect(searchfn).toHaveBeenNthCalledWith(2, expect.objectContaining({ pagination: { page: 2 }, search: { redirectResponse: 'full' } }));
expect(searchfn).toHaveBeenNthCalledWith(3, expect.objectContaining({ pagination: { page: 3 }, search: { redirectResponse: 'full' } }));

expect(controller.store.results.length).toBe(pageSize * page);

searchfn.mockClear();
Expand Down
17 changes: 16 additions & 1 deletion packages/snap-controller/src/Search/SearchController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export class SearchController extends AbstractController {
const params: SearchRequestModel = deepmerge({ ...getSearchParams(this.urlManager.state) }, this.config.globals || {});

// redirect setting
// DUPLICATED LOGIC can be found in infinite backfill (change both if updating)
if (!this.config.settings?.redirects?.merchandising || this.store.loaded) {
params.search = params.search || {};
params.search.redirectResponse = 'full' as SearchRequestModelSearchRedirectResponseEnum;
Expand Down Expand Up @@ -376,7 +377,21 @@ export class SearchController extends AbstractController {
const backfillRequests = Array(params.pagination.page)
.fill('backfill')
.map((v, i) => {
const backfillParams = deepmerge({ ...params }, { pagination: { page: i + 1 } });
const backfillParams: SearchRequestModel = deepmerge(
{ ...params },
{ pagination: { page: i + 1 }, search: { redirectResponse: 'full' } }
);
// don't include page parameter if on page 1
if (i + 1 == 1) {
delete backfillParams?.pagination?.page;

if (this.config.settings?.redirects?.merchandising) {
// redirect setting
// DUPLICATED LOGIC can be found in params getter
delete backfillParams?.search?.redirectResponse;
}
}

return this.client.search(backfillParams);
});

Expand Down

0 comments on commit 51239fd

Please sign in to comment.