Skip to content

Commit

Permalink
Revert "Merge query parameters back after Tweakwise Personal Merchand…
Browse files Browse the repository at this point in the history
…ier Refresh (#83)"

This reverts commit 1e91f83.
  • Loading branch information
ah-net committed Feb 15, 2024
1 parent 2f2d8bc commit cdab383
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
12 changes: 3 additions & 9 deletions view/frontend/web/js/navigation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ define([
* @private
*/
_updateState: function (response) {
const newUrl = this._buildUrlWithQueryString(response, true);
window.history.pushState({html: response.html}, '', newUrl);
window.history.pushState({html: response.html}, '', response.url);
},

/**
Expand All @@ -375,22 +374,17 @@ define([
* Merges existed query parameters with the ones get from AJAX response if needed
*
* @param response
* @param flip
* @returns string
* @private
*/
_buildUrlWithQueryString: function (response, flip = false) {
_buildUrlWithQueryString: function (response) {
const baseUrl = window.location.origin;
const resultUrl = new URL(response.url, baseUrl);
const queryParams = new URLSearchParams(window.location.search ?? '');
let queryParamsString = queryParams.toString();

if (resultUrl.search) {
if (flip) {
queryParamsString = this._combineQueryStrings(resultUrl.searchParams, queryParams);
} else {
queryParamsString = this._combineQueryStrings(queryParams, resultUrl.searchParams);
}
queryParamsString = this._combineQueryStrings(queryParams, resultUrl.searchParams);
}

resultUrl.search = queryParamsString;
Expand Down
7 changes: 1 addition & 6 deletions view/frontend/web/js/pm-page-reload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
*
* @copyright Copyright (c) 2017-2023 Tweakwise.com B.V. (https://www.tweakwise.com)
* @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

Expand All @@ -27,11 +27,6 @@ define([
&& this.options.cookieName
&& ($.mage.cookies.get(this.options.cookieName) !== null);
if (reload) {
const urlParams = new URLSearchParams(window.location.search);
const pageParam = urlParams.get('p');
if (pageParam) {
$(this.element.append('<input type="hidden" name="p" value="'+ parseInt(pageParam) +'" />'))
}
this.element.trigger('change');
}
}
Expand Down

0 comments on commit cdab383

Please sign in to comment.