mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-25 18:02:04 +00:00
EZQMS-642: Extended navigate()
signature to support History replacement (#4979)
Signed-off-by: Petr Vyazovetskiy <develop.pit@gmail.com>
This commit is contained in:
parent
487d753a9a
commit
8ead1c4ab8
@ -170,22 +170,22 @@ export function setLocationStorageKey (storageKey: string): void {
|
|||||||
locationStorageKeyId = storageKey
|
locationStorageKeyId = storageKey
|
||||||
}
|
}
|
||||||
|
|
||||||
export function navigate (location: PlatformLocation, store = true): boolean {
|
export function navigate (location: PlatformLocation, replace = false): boolean {
|
||||||
closePopup()
|
closePopup()
|
||||||
const cur = locationToUrl(getCurrentLocation())
|
const cur = locationToUrl(getCurrentLocation())
|
||||||
const url = locationToUrl(location)
|
const url = locationToUrl(location)
|
||||||
if (cur !== url) {
|
if (cur !== url) {
|
||||||
if (store) {
|
const data = !embeddedPlatform ? null : { location }
|
||||||
if (!embeddedPlatform) {
|
const _url = !embeddedPlatform ? url : undefined
|
||||||
history.pushState(null, '', url)
|
if (replace) {
|
||||||
|
history.replaceState(data, '', _url)
|
||||||
} else {
|
} else {
|
||||||
history.pushState({ location }, '')
|
history.pushState(data, '', _url)
|
||||||
}
|
}
|
||||||
localStorage.setItem(locationStorageKeyId, JSON.stringify(location))
|
localStorage.setItem(locationStorageKeyId, JSON.stringify(location))
|
||||||
if (location.path[1] !== undefined) {
|
if (location.path[1] !== undefined) {
|
||||||
localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location))
|
localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
locationWritable.set(location)
|
locationWritable.set(location)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user