|
|
|
@@ -16,15 +16,23 @@ const useQueryString = () => { |
|
|
|
const dispatch = useDispatch(); |
|
|
|
const [isInitiallyLoaded, setIsInitallyLoaded] = useState(false); |
|
|
|
const [queryObject, setQueryObject] = useState({}); |
|
|
|
const [historyStateCleared, setHistoryStateCleared] = useState(true); |
|
|
|
|
|
|
|
// Initially read filters, sorting and paging from querystring |
|
|
|
useEffect(() => { |
|
|
|
if ((!isInitiallyLoaded || history.location?.state?.logo) && !history.location?.state?.from) { |
|
|
|
if ( |
|
|
|
(!isInitiallyLoaded || history.location?.state?.logo) && |
|
|
|
!history.location?.state?.from |
|
|
|
) { |
|
|
|
const queryStringFromUrl = history.location?.search; |
|
|
|
setQueryObject(getQueryObjectHelper(queryStringFromUrl)); |
|
|
|
dispatch(setQueryString(queryStringFromUrl)); |
|
|
|
} |
|
|
|
history.location.state = {} |
|
|
|
if (history.location?.state?.logo) { |
|
|
|
setHistoryStateCleared(false); |
|
|
|
} else { |
|
|
|
setHistoryStateCleared(true); |
|
|
|
} |
|
|
|
}, [history.location]); |
|
|
|
|
|
|
|
// Set initially loaded to true on initial load |
|
|
|
@@ -55,6 +63,7 @@ const useQueryString = () => { |
|
|
|
queryString, |
|
|
|
queryObject, |
|
|
|
isInitiallyLoaded, |
|
|
|
historyStateCleared, |
|
|
|
}; |
|
|
|
}; |
|
|
|
export default useQueryString; |