mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-24 17:30:03 +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,21 +170,21 @@ export function setLocationStorageKey (storageKey: string): void {
|
||||
locationStorageKeyId = storageKey
|
||||
}
|
||||
|
||||
export function navigate (location: PlatformLocation, store = true): boolean {
|
||||
export function navigate (location: PlatformLocation, replace = false): boolean {
|
||||
closePopup()
|
||||
const cur = locationToUrl(getCurrentLocation())
|
||||
const url = locationToUrl(location)
|
||||
if (cur !== url) {
|
||||
if (store) {
|
||||
if (!embeddedPlatform) {
|
||||
history.pushState(null, '', url)
|
||||
} else {
|
||||
history.pushState({ location }, '')
|
||||
}
|
||||
localStorage.setItem(locationStorageKeyId, JSON.stringify(location))
|
||||
if (location.path[1] !== undefined) {
|
||||
localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location))
|
||||
}
|
||||
const data = !embeddedPlatform ? null : { location }
|
||||
const _url = !embeddedPlatform ? url : undefined
|
||||
if (replace) {
|
||||
history.replaceState(data, '', _url)
|
||||
} else {
|
||||
history.pushState(data, '', _url)
|
||||
}
|
||||
localStorage.setItem(locationStorageKeyId, JSON.stringify(location))
|
||||
if (location.path[1] !== undefined) {
|
||||
localStorage.setItem(`${locationStorageKeyId}_${location.path[1]}`, JSON.stringify(location))
|
||||
}
|
||||
locationWritable.set(location)
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user