From 450b577a98c8e41a5ded7e64db2859d866471c64 Mon Sep 17 00:00:00 2001 From: Farzad Yousefzadeh Date: Wed, 8 Sep 2021 19:39:38 +0300 Subject: [PATCH 1/2] set custom event origin to currentSessionId to be picked up by devtools and sent to the inspected source --- src/simulationMachine.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/simulationMachine.tsx b/src/simulationMachine.tsx index 4d699ce8..59722bba 100644 --- a/src/simulationMachine.tsx +++ b/src/simulationMachine.tsx @@ -303,7 +303,10 @@ export const simulationMachine = simModel.createMachine( (ctx, e) => { return { type: 'xstate.event', - event: e.event, + event: { + ...e.event, + origin: e.event.origin || ctx.currentSessionId, + }, sessionId: ctx.currentSessionId, }; }, From 7cc57c836c111eb1695a76b02de8f3d689cf59a6 Mon Sep 17 00:00:00 2001 From: Farzad Yousefzadeh Date: Wed, 8 Sep 2021 22:04:09 +0300 Subject: [PATCH 2/2] Fix bug with send button being disabled on valid JSON --- src/EventsPanel.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/EventsPanel.tsx b/src/EventsPanel.tsx index 66e321c9..22e31e13 100644 --- a/src/EventsPanel.tsx +++ b/src/EventsPanel.tsx @@ -343,9 +343,13 @@ const newEventMachine = newEventModel.createMachine({ on: { '*': [ { - cond: (ctx) => { + cond: (_, e) => { try { - const eventObject = JSON.parse(ctx.eventString); + const eventObject = JSON.parse( + (e as ReturnType< + typeof newEventModel.events['EVENT.PAYLOAD'] + >).value, + ); return typeof eventObject.type === 'string'; } catch (e) { return false;