@@ -167,51 +167,26 @@ function updateTypeActionsInWorkflow(workflow: any[], credentials: Credentials)
167167 return workflow . map ( step => {
168168 if ( ! step . what ) return step ;
169169
170- const indicesToRemove = new Set < number > ( ) ;
171- step . what . forEach ( ( action : any , index : number ) => {
172- if ( ! action . action || ! action . args ?. [ 0 ] ) return ;
173-
174- if ( ( action . action === 'type' || action . action === 'press' ) && credentials [ action . args [ 0 ] ] ) {
175- indicesToRemove . add ( index ) ;
176-
177- if ( step . what [ index + 1 ] ?. action === 'waitForLoadState' ) {
178- indicesToRemove . add ( index + 1 ) ;
179- }
180- }
181- } ) ;
182-
183- const filteredWhat = step . what . filter ( ( _ : any , index : number ) => ! indicesToRemove . has ( index ) ) ;
184-
185- Object . entries ( credentials ) . forEach ( ( [ selector , credentialInfo ] ) => {
186- const clickIndex = filteredWhat . findIndex ( ( action : any ) =>
187- action . action === 'click' && action . args ?. [ 0 ] === selector
188- ) ;
189-
190- if ( clickIndex !== - 1 ) {
191- const chars = credentialInfo . value . split ( '' ) ;
170+ step . what = step . what . map ( ( action : any ) => {
171+ if ( action . action === 'type' && action . args ?. length >= 2 ) {
172+ const selector = action . args [ 0 ] ;
192173
193- chars . forEach ( ( char , i ) => {
194- filteredWhat . splice ( clickIndex + 1 + ( i * 2 ) , 0 , {
195- action : 'type' ,
174+ if ( credentials [ selector ] ) {
175+ return {
176+ ... action ,
196177 args : [
197178 selector ,
198- encrypt ( char ) ,
199- credentialInfo . type
179+ encrypt ( credentials [ selector ] . value ) ,
180+ credentials [ selector ] . type
200181 ]
201- } ) ;
202-
203- filteredWhat . splice ( clickIndex + 2 + ( i * 2 ) , 0 , {
204- action : 'waitForLoadState' ,
205- args : [ 'networkidle' ]
206- } ) ;
207- } ) ;
182+ } ;
183+ }
208184 }
185+
186+ return action ;
209187 } ) ;
210188
211- return {
212- ...step ,
213- what : filteredWhat
214- } ;
189+ return step ;
215190 } ) ;
216191}
217192
@@ -281,9 +256,23 @@ router.put('/recordings/:id', requireSignIn, async (req: AuthenticatedRequest, r
281256 }
282257 }
283258
284- robot . set ( 'recording' , { ...robot . recording , workflow } ) ;
259+ const updates : any = {
260+ recording : {
261+ ...robot . recording ,
262+ workflow
263+ }
264+ } ;
285265
286- await robot . save ( ) ;
266+ if ( name ) {
267+ updates . recording_meta = {
268+ ...robot . recording_meta ,
269+ name
270+ } ;
271+ }
272+
273+ await Robot . update ( updates , {
274+ where : { 'recording_meta.id' : id }
275+ } ) ;
287276
288277 const updatedRobot = await Robot . findOne ( { where : { 'recording_meta.id' : id } } ) ;
289278
0 commit comments