@@ -27,6 +27,9 @@ const activateStage = index => {
27
27
} ;
28
28
29
29
class AnimateTrade extends Component {
30
+ componentDidUpdate ( prevProps , prevState ) {
31
+ console . log ( { prevState, state : this . state } ) ;
32
+ }
30
33
constructor ( ) {
31
34
super ( ) ;
32
35
this . indicatorMessages = {
@@ -42,6 +45,12 @@ class AnimateTrade extends Component {
42
45
} ;
43
46
}
44
47
componentWillMount ( ) {
48
+ const resetSummary = ( ) => {
49
+ resetAnimation ( ) ;
50
+ this . setState ( { indicatorMessage : this . indicatorMessages . notRunning } ) ;
51
+ } ;
52
+ globalObserver . register ( 'reset_animation' , resetSummary ) ;
53
+ globalObserver . register ( 'summary.clear' , resetSummary ) ;
45
54
globalObserver . register ( 'bot.running' , ( ) => {
46
55
$ ( '.stage-tooltip.top:eq(0)' ) . addClass ( 'running' ) ;
47
56
this . setState ( { indicatorMessage : this . indicatorMessages . running } ) ;
@@ -50,40 +59,31 @@ class AnimateTrade extends Component {
50
59
$ ( '.stage-tooltip.top:eq(0)' ) . removeClass ( 'running' ) ;
51
60
this . setState ( { indicatorMessage : this . indicatorMessages . stopped } ) ;
52
61
} ) ;
53
- globalObserver . register ( 'reset_animation' , ( ) => {
54
- resetAnimation ( ) ;
55
- this . setState ( { indicatorMessage : this . indicatorMessages . stopped } ) ;
56
- } ) ;
57
-
58
62
$ ( '#stopButton' ) . click ( ( ) => {
59
63
$ ( '.stage-tooltip.top:eq(0)' ) . removeClass ( 'running' ) ;
60
- this . setState ( { indicatorMessage : this . state . stopMessage } ) ;
64
+ this . setState ( {
65
+ indicatorMessage : globalObserver . getState ( 'isRunning' )
66
+ ? this . indicatorMessages . stopping
67
+ : this . indicatorMessages . stopped ,
68
+ } ) ;
61
69
} ) ;
62
-
63
70
$ ( '#runButton' ) . click ( ( ) => {
64
71
resetAnimation ( ) ;
65
72
$ ( '.stage-tooltip.top:eq(0)' ) . addClass ( 'running' ) ;
66
- this . setState ( {
67
- indicatorMessage : this . indicatorMessages . starting ,
68
- stopMessage : this . indicatorMessages . stopped ,
69
- } ) ;
73
+ this . setState ( { indicatorMessage : this . indicatorMessages . starting } ) ;
70
74
globalObserver . emit ( 'summary.disable_clear' ) ;
71
- globalObserver . register ( 'contract.status' , contractStatus => {
72
- this . animateStage ( contractStatus ) ;
73
- } ) ;
75
+ globalObserver . register ( 'contract.status' , contractStatus => this . animateStage ( contractStatus ) ) ;
74
76
} ) ;
75
77
}
76
78
animateStage ( contractStatus ) {
77
79
if ( contractStatus . id === 'contract.purchase_sent' ) {
78
80
resetAnimation ( ) ;
79
81
activateStage ( 0 ) ;
80
-
81
82
this . setState ( {
82
83
buy_price : roundBalance ( {
83
84
balance : contractStatus . proposal . ask_price ,
84
85
currency : contractStatus . currency ,
85
86
} ) ,
86
- stopMessage : this . indicatorMessages . stopping ,
87
87
} ) ;
88
88
} else if ( contractStatus . id === 'contract.purchase_recieved' ) {
89
89
$ ( '.line' ) . addClass ( 'active' ) ;
@@ -92,7 +92,7 @@ class AnimateTrade extends Component {
92
92
} else if ( contractStatus . id === 'contract.sold' ) {
93
93
$ ( '.line' ) . addClass ( 'complete' ) ;
94
94
activateStage ( 2 ) ;
95
- this . setState ( { sell_id : contractStatus . data , stopMessage : this . indicatorMessages . stopped } ) ;
95
+ this . setState ( { sell_id : contractStatus . data } ) ;
96
96
}
97
97
98
98
activateStage ( contractStatus . id ) ;
0 commit comments