2
0

(chatwoot) Unmount Typebot embed bubble when opening chatwoot

Closes #1007
This commit is contained in:
Baptiste Arnaud
2023-11-06 16:57:05 +01:00
parent b2b82c48e1
commit eed562b47a
11 changed files with 40 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
import styles from '../../../assets/index.css'
import { Bot, BotProps } from '@/components/Bot'
import { CommandData } from '@/features/commands/types'
import { createSignal, onCleanup, onMount, Show } from 'solid-js'
const hostElementCss = `
@@ -27,9 +28,16 @@ export const Standard = (
})
onMount(() => {
window.addEventListener('message', processIncomingEvent)
botLauncherObserver.observe(element)
})
const processIncomingEvent = (event: MessageEvent<CommandData>) => {
const { data } = event
if (!data.isFromTypebot) return
if (data.command === 'unmount') setIsBotDisplayed(false)
}
onCleanup(() => {
botLauncherObserver.disconnect()
})