Skip to content

Commit 7804aea

Browse files
Challenges bug bash (#75)
* issue topcoder-platform/micro-frontends-challenges-app#143 (#73) * ci: deploy * reset ci Co-authored-by: Nguyen Viet <36178659+nqviet@users.noreply.github.com>
1 parent cd7bbbe commit 7804aea

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/actions/gigs/effectors.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,18 @@ export const loadSkills = async ({ dispatch, getState }) => {
137137
* URL query by replacing URL in history.
138138
*
139139
* @param {Object} store redux store object
140+
* @param {Object} options.mountLocation location object
140141
*/
141-
export const updateStateAndQuery = ({ dispatch, getState }) => {
142+
export const updateStateAndQuery = ({ dispatch, getState }, options) => {
143+
const location = options ? options.mountLocation : window.location;
144+
const isGigsLocation = location.pathname === window.location.pathname;
145+
142146
dispatch(actions.updateStateFromQuery(location.search));
143147
const query = makeQueryFromState(selectors.getStateSlice(getState()));
144-
window.history.replaceState(null, "", `${location.pathname}?${query}`);
148+
149+
if (isGigsLocation) {
150+
window.history.replaceState(null, "", `${location.pathname}?${query}`);
151+
}
145152
};
146153

147154
/**

src/containers/Gigs/index.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ import { setReferralCookie } from "utils/referral";
1818
* normalizes query. Then depending on if state has changed loads gigs page.
1919
*/
2020
const onMount = async () => {
21+
const mountLocation = {
22+
search: window.location.search,
23+
pathname: window.location.pathname,
24+
};
2125
setReferralCookie();
2226
const hasInitialData = selectors.getHasInitialData(store.getState());
2327
if (!hasInitialData) {
2428
await effectors.loadInitialData(store);
2529
}
2630
const stateOld = store.getState();
27-
effectors.updateStateAndQuery(store);
31+
const options = { mountLocation };
32+
effectors.updateStateAndQuery(store, options);
2833
if (stateOld === store.getState() && !hasInitialData) {
2934
// If after updating state from query the state stays the same we need to
3035
// manually load gigs. In other case gigs will be loaded by useUpdateEffect

0 commit comments

Comments
 (0)