♻️ Use at function instead of dangerous direct lookup array index
This commit is contained in:
@ -19,5 +19,5 @@ export const getFirstEdgeId = ({
|
||||
return event.outgoingEdgeId
|
||||
}
|
||||
if (typebot.version === '6') return typebot.events[0].outgoingEdgeId
|
||||
return typebot.groups[0].blocks[0].outgoingEdgeId
|
||||
return typebot.groups.at(0)?.blocks.at(0)?.outgoingEdgeId
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ export const getBlockById = (
|
||||
for (let groupIndex = 0; groupIndex < groups.length; groupIndex++) {
|
||||
for (
|
||||
let blockIndex = 0;
|
||||
blockIndex < groups[groupIndex].blocks.length;
|
||||
blockIndex < (groups.at(groupIndex)?.blocks?.length ?? 0);
|
||||
blockIndex++
|
||||
) {
|
||||
if (groups[groupIndex].blocks[blockIndex].id === blockId) {
|
||||
if (groups.at(groupIndex)?.blocks?.at(blockIndex)?.id === blockId) {
|
||||
return {
|
||||
block: groups[groupIndex].blocks[blockIndex],
|
||||
group: groups[groupIndex],
|
||||
|
Reference in New Issue
Block a user