2
0

🐛 Fix crash when outgoing edge blockId does not exist

This commit is contained in:
Baptiste Arnaud
2023-01-31 08:52:00 +01:00
parent 3851b2d70b
commit 58ca1c3ad6
3 changed files with 10 additions and 2 deletions

View File

@ -130,6 +130,11 @@ const moveBlockToGroup = (
: (newBlock.outgoingEdgeId = undefined) : (newBlock.outgoingEdgeId = undefined)
} }
} }
typebot.edges.forEach((edge) => {
if (edge.to.blockId === block.id) {
edge.to.groupId = groupId
}
})
typebot.groups[groupIndex].blocks.splice(blockIndex ?? 0, 0, newBlock) typebot.groups[groupIndex].blocks.splice(blockIndex ?? 0, 0, newBlock)
} }

View File

@ -2,7 +2,7 @@
* Instantiates a single instance PrismaClient and save it on the global object. * Instantiates a single instance PrismaClient and save it on the global object.
* @link https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices * @link https://www.prisma.io/docs/support/help-articles/nextjs-prisma-client-dev-practices
*/ */
import { PrismaClient } from '@prisma/client' import { PrismaClient } from 'db'
const prismaGlobal = global as typeof global & { const prismaGlobal = global as typeof global & {
prisma?: PrismaClient prisma?: PrismaClient

View File

@ -78,7 +78,10 @@ export const ConversationContainer = ({
onNewGroupVisible(nextEdge) onNewGroupVisible(nextEdge)
setDisplayedGroups([ setDisplayedGroups([
...displayedGroups, ...displayedGroups,
{ group: nextGroup, startBlockIndex }, {
group: nextGroup,
startBlockIndex: startBlockIndex === -1 ? 0 : startBlockIndex,
},
]) ])
} }