diff --git a/src/actions/gigs/effectors.js b/src/actions/gigs/effectors.js index 6be90af..edcb9f1 100644 --- a/src/actions/gigs/effectors.js +++ b/src/actions/gigs/effectors.js @@ -137,11 +137,18 @@ export const loadSkills = async ({ dispatch, getState }) => { * URL query by replacing URL in history. * * @param {Object} store redux store object + * @param {Object} options.mountLocation location object */ -export const updateStateAndQuery = ({ dispatch, getState }) => { +export const updateStateAndQuery = ({ dispatch, getState }, options) => { + const location = options ? options.mountLocation : window.location; + const isGigsLocation = location.pathname === window.location.pathname; + dispatch(actions.updateStateFromQuery(location.search)); const query = makeQueryFromState(selectors.getStateSlice(getState())); - window.history.replaceState(null, "", `${location.pathname}?${query}`); + + if (isGigsLocation) { + window.history.replaceState(null, "", `${location.pathname}?${query}`); + } }; /** diff --git a/src/containers/Gigs/index.jsx b/src/containers/Gigs/index.jsx index 2b43b39..73123fe 100644 --- a/src/containers/Gigs/index.jsx +++ b/src/containers/Gigs/index.jsx @@ -18,13 +18,18 @@ import { setReferralCookie } from "utils/referral"; * normalizes query. Then depending on if state has changed loads gigs page. */ const onMount = async () => { + const mountLocation = { + search: window.location.search, + pathname: window.location.pathname, + }; setReferralCookie(); const hasInitialData = selectors.getHasInitialData(store.getState()); if (!hasInitialData) { await effectors.loadInitialData(store); } const stateOld = store.getState(); - effectors.updateStateAndQuery(store); + const options = { mountLocation }; + effectors.updateStateAndQuery(store, options); if (stateOld === store.getState() && !hasInitialData) { // If after updating state from query the state stays the same we need to // manually load gigs. In other case gigs will be loaded by useUpdateEffect