mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-25 21:01:54 +08:00
🚸 Only execute reply event with outgoind edge id
This commit is contained in:
parent
0c883b9a11
commit
45f7e2ca5e
@ -943,10 +943,12 @@ export const safeJsonParse = (value: string): unknown => {
|
||||
}
|
||||
};
|
||||
|
||||
const findReplyEvent = (state: SessionState): ReplyEvent | undefined =>
|
||||
const findReplyEvent = (
|
||||
state: SessionState,
|
||||
): (ReplyEvent & { outgoingEdgeId: string }) | undefined =>
|
||||
state.typebotsQueue[0].typebot.events?.find(
|
||||
(e) => e.type === EventType.REPLY,
|
||||
);
|
||||
(e) => e.type === EventType.REPLY && e.outgoingEdgeId,
|
||||
) as (ReplyEvent & { outgoingEdgeId: string }) | undefined;
|
||||
|
||||
const findInvalidReplyEvent = (
|
||||
state: SessionState,
|
||||
|
||||
@ -10,8 +10,15 @@ type Props = {
|
||||
reply: InputMessage;
|
||||
};
|
||||
|
||||
type ReplyEventWithDefinedOutgoingEdgeId = Omit<
|
||||
ReplyEvent,
|
||||
"outgoingEdgeId"
|
||||
> & {
|
||||
outgoingEdgeId: string;
|
||||
};
|
||||
|
||||
export const executeReplyEvent = (
|
||||
event: ReplyEvent,
|
||||
event: ReplyEventWithDefinedOutgoingEdgeId,
|
||||
{ state, reply }: Props,
|
||||
) => {
|
||||
if (!state.currentBlockId)
|
||||
|
||||
@ -5,7 +5,7 @@ import { addDummyFirstBlockToGroupIfMissing } from "../addDummyFirstBlockToGroup
|
||||
|
||||
type Props = {
|
||||
state: SessionState;
|
||||
event: TDraggableEvent;
|
||||
event: TDraggableEvent & { outgoingEdgeId: string };
|
||||
};
|
||||
|
||||
export const updateCurrentBlockIdWithEvent = ({ state, event }: Props) => {
|
||||
@ -14,10 +14,11 @@ export const updateCurrentBlockIdWithEvent = ({ state, event }: Props) => {
|
||||
const edge = newSessionState.typebotsQueue[0].typebot.edges.find(
|
||||
(edge) => edge.id === event.outgoingEdgeId,
|
||||
);
|
||||
|
||||
if (!edge)
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Event is not connected",
|
||||
message: `Could not find outgoing edge`,
|
||||
});
|
||||
|
||||
newSessionState = addDummyFirstBlockToGroupIfMissing(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user