@@ -92,28 +92,38 @@ export const stateToAction = (settings: NodeEditorSettings, state: SendMsgFormSt
92
92
93
93
let templating : MsgTemplating = null ;
94
94
if ( state . template && state . template . value ) {
95
- const components = Object . keys ( state . templateTranslation . components ) . map ( ( key : string ) => {
96
- let uuid = createUUID ( ) ;
97
-
98
- // try looking up the uuid from the original action
99
- if ( settings . originalAction && settings . originalAction . type === Types . send_msg ) {
100
- const originalAction = settings . originalAction as SendMsg ;
101
- if ( originalAction . templating ) {
102
- const originalComponent = originalAction . templating . components . find (
103
- ( component : any ) => component . name === key
104
- ) ;
105
- if ( originalComponent ) {
106
- uuid = originalComponent . uuid ;
95
+ const originalAction =
96
+ settings . originalAction . type === Types . send_msg ? ( settings . originalAction as SendMsg ) : null ;
97
+
98
+ let components =
99
+ originalAction . templating && originalAction . templating . components
100
+ ? originalAction . templating . components
101
+ : [ ] ;
102
+
103
+ if ( state . templateTranslation ) {
104
+ components = Object . keys ( state . templateTranslation . components ) . map ( ( key : string ) => {
105
+ let uuid = createUUID ( ) ;
106
+
107
+ // try looking up the uuid from the original action
108
+ if ( settings . originalAction && settings . originalAction . type === Types . send_msg ) {
109
+ const originalAction = settings . originalAction as SendMsg ;
110
+ if ( originalAction . templating ) {
111
+ const originalComponent = originalAction . templating . components . find (
112
+ ( component : any ) => component . name === key
113
+ ) ;
114
+ if ( originalComponent ) {
115
+ uuid = originalComponent . uuid ;
116
+ }
107
117
}
108
118
}
109
- }
110
119
111
- return {
112
- uuid,
113
- name : key ,
114
- params : state . paramsByTemplate [ state . template . value . uuid ] [ key ]
115
- } ;
116
- } ) ;
120
+ return {
121
+ uuid,
122
+ name : key ,
123
+ params : state . paramsByTemplate [ state . template . value . uuid ] [ key ]
124
+ } ;
125
+ } ) ;
126
+ }
117
127
118
128
templating = {
119
129
template : {
0 commit comments