code review, simplify iframeTemplate
This commit is contained in:
parent
753d2f51bc
commit
b66d76f010
|
@ -95,12 +95,12 @@
|
|||
const handlers = {
|
||||
[MessageTypes.READY]: () => {
|
||||
// Initialise the app when mounted
|
||||
// Display preview immediately if the intelligent loading feature
|
||||
// is not supported
|
||||
if ($store.clientFeatures.messagePassing) {
|
||||
if (!loading) return
|
||||
}
|
||||
|
||||
// Display preview immediately if the intelligent loading feature
|
||||
// is not supported
|
||||
if (!$store.clientFeatures.intelligentLoading) {
|
||||
loading = false
|
||||
}
|
||||
|
@ -119,9 +119,8 @@
|
|||
}
|
||||
|
||||
onMount(() => {
|
||||
if ($store.clientFeatures.messagePassing) {
|
||||
window.addEventListener("message", receiveMessage)
|
||||
} else {
|
||||
window.addEventListener("message", receiveMessage)
|
||||
if (!$store.clientFeatures.messagePassing) {
|
||||
// Legacy - remove in later versions of BB
|
||||
iframe.contentWindow.addEventListener("ready", () => {
|
||||
receiveMessage({ data: { type: MessageTypes.READY }})
|
||||
|
@ -138,9 +137,8 @@
|
|||
// Remove all iframe event listeners on component destroy
|
||||
onDestroy(() => {
|
||||
if (iframe.contentWindow) {
|
||||
if ($store.clientFeatures.messagePassing) {
|
||||
window.removeEventListener("message", receiveMessage)
|
||||
} else {
|
||||
window.removeEventListener("message", receiveMessage)
|
||||
if (!$store.clientFeatures.messagePassing) {
|
||||
// Legacy - remove in later versions of BB
|
||||
iframe.contentWindow.removeEventListener("bb-event", handleBudibaseEvent)
|
||||
iframe.contentWindow.removeEventListener("keydown", handleKeydownEvent)
|
||||
|
|
|
@ -65,7 +65,6 @@ export default `
|
|||
theme,
|
||||
customTheme,
|
||||
previewDevice,
|
||||
messagePassing
|
||||
} = parsed
|
||||
|
||||
// Set some flags so the app knows we're in the builder
|
||||
|
@ -90,11 +89,7 @@ export default `
|
|||
throw "The client library couldn't be loaded"
|
||||
}
|
||||
} catch (error) {
|
||||
if (messagePassing) {
|
||||
window.parent.postMessage({ type: "error", error })
|
||||
} else {
|
||||
window.dispatchEvent(new CustomEvent("error", { detail: error }))
|
||||
}
|
||||
window.parent.postMessage({ type: "error", error })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +99,6 @@ export default `
|
|||
})
|
||||
|
||||
window.parent.postMessage({ type: "ready" })
|
||||
window.dispatchEvent(new Event("ready"))
|
||||
</script>
|
||||
</head>
|
||||
<body/>
|
||||
|
|
|
@ -81,13 +81,12 @@ export function createAuthStore() {
|
|||
}
|
||||
|
||||
async function setInitInfo(info) {
|
||||
const response = await api.post(`/api/global/auth/init`, info)
|
||||
const json = await response.json()
|
||||
await api.post(`/api/global/auth/init`, info)
|
||||
auth.update(store => {
|
||||
store.initInfo = json
|
||||
store.initInfo = info
|
||||
return store
|
||||
})
|
||||
return json
|
||||
return info
|
||||
}
|
||||
|
||||
async function getInitInfo() {
|
||||
|
@ -102,7 +101,7 @@ export function createAuthStore() {
|
|||
|
||||
return {
|
||||
subscribe: store.subscribe,
|
||||
setOrganisation: setOrganisation,
|
||||
setOrganisation,
|
||||
getInitInfo,
|
||||
setInitInfo,
|
||||
checkQueryString: async () => {
|
||||
|
|
Loading…
Reference in New Issue