1
1
import { PAGE_SET } from '../types' ;
2
- import handleActionString from './handle-action-string' ;
3
-
4
- function handleTaskActions ( actions : string [ ] [ ] ) : void {
5
- const next = actions . shift ( ) ;
6
- if ( next && next . length ) {
7
- // resolve promises in order
8
- next . reduce ( ( total : Promise < any > , curr : string ) => {
9
- return total . then ( ( ) => handleActionString ( curr ) ) ;
10
- } , Promise . resolve ( ) ) ;
11
- }
12
- }
2
+ import handleTaskActions from './handle-actions' ;
13
3
14
4
// trigger actions only once, moving fowards
15
- let taskTracker = 0 ;
5
+ let taskPositionTracker = 0 ;
16
6
17
7
export default function taskActionsReducer (
18
8
taskActions = [ ] , action : Action
@@ -32,22 +22,21 @@ export default function taskActionsReducer(
32
22
return task . actions . filter ( a => ! ! a . match ( / ^ o p e n / ) ) ;
33
23
} ) ;
34
24
}
35
- taskTracker = 0 ;
25
+ taskPositionTracker = 0 ;
36
26
handleTaskActions ( actions ) ; // run first action
37
27
return actions ;
38
28
39
29
// run task actions
40
30
case 'TEST_RESULT' :
41
31
actions = action . payload . taskActions || [ ] ;
42
32
const nextTaskPosition = action . payload . result . taskPosition ;
43
- const times : number = nextTaskPosition - taskTracker ;
44
-
33
+ const times : number = nextTaskPosition - taskPositionTracker ;
45
34
if ( times > 0 ) {
46
35
// run actions for each task position passed
47
36
for ( let i = 0 ; i < times ; i ++ ) {
48
37
handleTaskActions ( actions ) ; // run first action
49
38
}
50
- taskTracker = nextTaskPosition ;
39
+ taskPositionTracker = nextTaskPosition ;
51
40
}
52
41
return actions ;
53
42
0 commit comments