Prevent unnecessary URL param updates in design page
This commit is contained in:
parent
b1c292b79c
commit
a16ea4da09
|
@ -8,6 +8,11 @@
|
||||||
|
|
||||||
let initialised = false
|
let initialised = false
|
||||||
|
|
||||||
|
// Cache previous values so we don't update the URL more than necessary
|
||||||
|
let previousType
|
||||||
|
let previousAsset
|
||||||
|
let previousComponentId
|
||||||
|
|
||||||
// Hydrate state from query param on mount
|
// Hydrate state from query param on mount
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const assetId = decodeURI($params.asset)
|
const assetId = decodeURI($params.asset)
|
||||||
|
@ -48,6 +53,19 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check we have different params than last invocation
|
||||||
|
if (
|
||||||
|
assetType === previousType &&
|
||||||
|
asset === previousAsset &&
|
||||||
|
componentId === previousComponentId
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
previousType = assetType
|
||||||
|
previousAsset = asset
|
||||||
|
previousComponentId = componentId
|
||||||
|
}
|
||||||
|
|
||||||
// Extract current URL params
|
// Extract current URL params
|
||||||
const currentParams = get(params)
|
const currentParams = get(params)
|
||||||
const currentLeftover = get(leftover)
|
const currentLeftover = get(leftover)
|
||||||
|
|
Loading…
Reference in New Issue