2
0

🐛 (web) Dynamic first host avatar not displaying in viewer

This commit is contained in:
Baptiste Arnaud
2024-01-18 11:13:45 +01:00
parent d6f94d37d8
commit 98107ee636
6 changed files with 32 additions and 27 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/js", "name": "@typebot.io/js",
"version": "0.2.32", "version": "0.2.33",
"description": "Javascript library to display typebots on your website", "description": "Javascript library to display typebots on your website",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -86,31 +86,30 @@ export const ConversationContainer = (props: Props) => {
onMount(() => { onMount(() => {
;(async () => { ;(async () => {
const initialChunk = chatChunks()[0] const initialChunk = chatChunks()[0]
if (initialChunk.clientSideActions) { if (!initialChunk.clientSideActions) return
const actionsBeforeFirstBubble = initialChunk.clientSideActions.filter( const actionsBeforeFirstBubble = initialChunk.clientSideActions.filter(
(action) => isNotDefined(action.lastBubbleBlockId) (action) => isNotDefined(action.lastBubbleBlockId)
)
for (const action of actionsBeforeFirstBubble) {
if (
'streamOpenAiChatCompletion' in action ||
'webhookToExecute' in action
) )
for (const action of actionsBeforeFirstBubble) { setIsSending(true)
if ( const response = await executeClientSideAction({
'streamOpenAiChatCompletion' in action || clientSideAction: action,
'webhookToExecute' in action context: {
) apiHost: props.context.apiHost,
setIsSending(true) sessionId: props.initialChatReply.sessionId,
const response = await executeClientSideAction({ },
clientSideAction: action, onMessageStream: streamMessage,
context: { })
apiHost: props.context.apiHost, if (response && 'replyToSend' in response) {
sessionId: props.initialChatReply.sessionId, sendMessage(response.replyToSend, response.logs)
}, return
onMessageStream: streamMessage,
})
if (response && 'replyToSend' in response) {
sendMessage(response.replyToSend, response.logs)
return
}
if (response && 'blockedPopupUrl' in response)
setBlockedPopupUrl(response.blockedPopupUrl)
} }
if (response && 'blockedPopupUrl' in response)
setBlockedPopupUrl(response.blockedPopupUrl)
} }
})() })()
}) })

View File

@ -8,7 +8,7 @@ export const Avatar = (props: { initialAvatarSrc?: string }) => {
createEffect(() => { createEffect(() => {
if ( if (
avatarSrc()?.startsWith('{{') && (avatarSrc()?.startsWith('{{') || !avatarSrc()) &&
props.initialAvatarSrc?.startsWith('http') props.initialAvatarSrc?.startsWith('http')
) )
setAvatarSrc(props.initialAvatarSrc) setAvatarSrc(props.initialAvatarSrc)

View File

@ -34,6 +34,8 @@ export const BubbleButton = (props: Props) => (
> >
<Show when={isNotDefined(props.customIconSrc)} keyed> <Show when={isNotDefined(props.customIconSrc)} keyed>
<svg <svg
//@ts-expect-error part exists
part="button-icon"
viewBox="0 0 24 24" viewBox="0 0 24 24"
style={{ style={{
stroke: stroke:
@ -70,6 +72,7 @@ export const BubbleButton = (props: Props) => (
</Show> </Show>
<Show when={props.customIconSrc && !isImageSrc(props.customIconSrc)}> <Show when={props.customIconSrc && !isImageSrc(props.customIconSrc)}>
<span <span
part="button-icon"
class={clsx( class={clsx(
'text-4xl duration-200 transition', 'text-4xl duration-200 transition',
props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100' props.isBotOpened ? 'scale-0 opacity-0' : 'scale-100 opacity-100'
@ -84,6 +87,8 @@ export const BubbleButton = (props: Props) => (
</Show> </Show>
<Show when={isNotDefined(props.customCloseIconSrc)}> <Show when={isNotDefined(props.customCloseIconSrc)}>
<svg <svg
//@ts-expect-error part exists
part="button-icon"
viewBox="0 0 24 24" viewBox="0 0 24 24"
style={{ style={{
fill: fill:
@ -132,6 +137,7 @@ export const BubbleButton = (props: Props) => (
when={props.customCloseIconSrc && !isImageSrc(props.customCloseIconSrc)} when={props.customCloseIconSrc && !isImageSrc(props.customCloseIconSrc)}
> >
<span <span
part="button-icon"
class={clsx( class={clsx(
'absolute text-4xl duration-200 transition', 'absolute text-4xl duration-200 transition',
props.isBotOpened props.isBotOpened

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/nextjs", "name": "@typebot.io/nextjs",
"version": "0.2.31", "version": "0.2.33",
"description": "Convenient library to display typebots on your Next.js website", "description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/react", "name": "@typebot.io/react",
"version": "0.2.32", "version": "0.2.33",
"description": "Convenient library to display typebots on your React app", "description": "Convenient library to display typebots on your React app",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",