1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

Navigate in PeekScreenDisplay

This commit is contained in:
Mel O'Hagan 2022-09-29 14:10:34 +01:00
parent df5d609298
commit 9a9ea26cc4
2 changed files with 4 additions and 20 deletions

View file

@ -45,6 +45,9 @@
},
[MessageTypes.CLOSE_SCREEN_MODAL]: () => {
peekStore.actions.hidePeek()
if (message.data?.url) {
routeStore.actions.navigate(message.data.url)
}
},
[MessageTypes.INVALIDATE_DATASOURCE]: () => {
proxyInvalidation(message.data)

View file

@ -226,28 +226,9 @@ const changeFormStepHandler = async (action, context) => {
const closeScreenModalHandler = action => {
let { url } = action.parameters
if (url) {
window.parent.addEventListener("message", event => {
const location = event.target.location
//remove any trailing slash
if (url.charAt(url.length - 1) === "/") {
url = url.substring(0, url.length - 1)
}
//need to reload if hash route has not changed
let shouldReload =
`#${url.substring(0, url.lastIndexOf("/"))}` ===
location.hash?.substring(0, location.hash.lastIndexOf("/"))
window.parent.location.href = `${location.origin}${location.pathname}#${url}`
if (shouldReload) {
window.parent.location.reload()
}
})
}
// Emit this as a window event, so parent screens which are iframing us in
// can close the modal
window.parent.postMessage({ type: "close-screen-modal" })
window.parent.postMessage({ type: "close-screen-modal", url })
}
const updateStateHandler = action => {