File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -137,11 +137,18 @@ export const loadSkills = async ({ dispatch, getState }) => {
137
137
* URL query by replacing URL in history.
138
138
*
139
139
* @param {Object } store redux store object
140
+ * @param {Object } options.mountLocation location object
140
141
*/
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
+
142
146
dispatch ( actions . updateStateFromQuery ( location . search ) ) ;
143
147
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
+ }
145
152
} ;
146
153
147
154
/**
Original file line number Diff line number Diff line change @@ -18,13 +18,18 @@ import { setReferralCookie } from "utils/referral";
18
18
* normalizes query. Then depending on if state has changed loads gigs page.
19
19
*/
20
20
const onMount = async ( ) => {
21
+ const mountLocation = {
22
+ search : window . location . search ,
23
+ pathname : window . location . pathname ,
24
+ } ;
21
25
setReferralCookie ( ) ;
22
26
const hasInitialData = selectors . getHasInitialData ( store . getState ( ) ) ;
23
27
if ( ! hasInitialData ) {
24
28
await effectors . loadInitialData ( store ) ;
25
29
}
26
30
const stateOld = store . getState ( ) ;
27
- effectors . updateStateAndQuery ( store ) ;
31
+ const options = { mountLocation } ;
32
+ effectors . updateStateAndQuery ( store , options ) ;
28
33
if ( stateOld === store . getState ( ) && ! hasInitialData ) {
29
34
// If after updating state from query the state stays the same we need to
30
35
// manually load gigs. In other case gigs will be loaded by useUpdateEffect
You can’t perform that action at this time.
0 commit comments