2
0

🐛 Fix progress bar crash when input is undefined

This commit is contained in:
Baptiste Arnaud
2024-03-11 08:56:50 +01:00
parent 22fe50268a
commit bbeb12cad2
4 changed files with 5 additions and 4 deletions

View File

@ -113,7 +113,7 @@ export const continueChat = publicProcedure
: computeCurrentProgress({ : computeCurrentProgress({
typebotsQueue: newSessionState.typebotsQueue, typebotsQueue: newSessionState.typebotsQueue,
progressMetadata: newSessionState.progressMetadata, progressMetadata: newSessionState.progressMetadata,
currentInputBlockId: input?.id as string, currentInputBlockId: input?.id,
}) })
: undefined, : undefined,
} }

View File

@ -109,7 +109,7 @@ export const startChat = publicProcedure
: computeCurrentProgress({ : computeCurrentProgress({
typebotsQueue: newSessionState.typebotsQueue, typebotsQueue: newSessionState.typebotsQueue,
progressMetadata: newSessionState.progressMetadata, progressMetadata: newSessionState.progressMetadata,
currentInputBlockId: input?.id as string, currentInputBlockId: input?.id,
}) })
: undefined, : undefined,
} }

View File

@ -98,7 +98,7 @@ export const startChatPreview = publicProcedure
: computeCurrentProgress({ : computeCurrentProgress({
typebotsQueue: newSessionState.typebotsQueue, typebotsQueue: newSessionState.typebotsQueue,
progressMetadata: newSessionState.progressMetadata, progressMetadata: newSessionState.progressMetadata,
currentInputBlockId: input?.id as string, currentInputBlockId: input?.id,
}) })
: undefined, : undefined,
} }

View File

@ -5,7 +5,7 @@ import { Block, SessionState } from '@typebot.io/schemas'
type Props = { type Props = {
typebotsQueue: SessionState['typebotsQueue'] typebotsQueue: SessionState['typebotsQueue']
progressMetadata: NonNullable<SessionState['progressMetadata']> progressMetadata: NonNullable<SessionState['progressMetadata']>
currentInputBlockId: string currentInputBlockId: string | undefined
} }
export const computeCurrentProgress = ({ export const computeCurrentProgress = ({
@ -13,6 +13,7 @@ export const computeCurrentProgress = ({
progressMetadata, progressMetadata,
currentInputBlockId, currentInputBlockId,
}: Props) => { }: Props) => {
if (!currentInputBlockId) return
const paths = computePossibleNextInputBlocks({ const paths = computePossibleNextInputBlocks({
typebotsQueue: typebotsQueue, typebotsQueue: typebotsQueue,
blockId: currentInputBlockId, blockId: currentInputBlockId,