File tree Expand file tree Collapse file tree 3 files changed +18
-14
lines changed
src/botPage/bot/TradeEngine Expand file tree Collapse file tree 3 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export default Engine => class OpenContract extends Engine {
21
21
this . ongoingPurchase = false
22
22
this . contractId = ''
23
23
this . updateTotals ( contract )
24
- this . api . unsubscribeByID ( this . openContractId )
25
24
if ( this . afterPromise ) {
26
25
this . afterPromise ( )
27
26
}
@@ -59,9 +58,7 @@ export default Engine => class OpenContract extends Engine {
59
58
doUntilDone ( ( ) => this . api . subscribeToTransactions ( ) )
60
59
}
61
60
62
- doUntilDone ( ( ) => this . api . subscribeToOpenContract ( contractId ) ) . then ( r => {
63
- ( { proposal_open_contract : { id : this . openContractId } } = r )
64
- } )
61
+ doUntilDone ( ( ) => this . api . subscribeToOpenContract ( contractId ) )
65
62
}
66
63
setContractFlags ( contract ) {
67
64
const {
Original file line number Diff line number Diff line change @@ -26,11 +26,14 @@ export default Engine => class Proposal extends Engine {
26
26
throw translate ( 'Selected proposal does not exist' )
27
27
}
28
28
29
- return toBuy
29
+ return {
30
+ id : toBuy . id ,
31
+ askPrice : toBuy . ask_price ,
32
+ }
30
33
}
31
- renewProposalsOnPurchase ( ) {
32
- this . unsubscribeProposals ( )
34
+ renewProposalsOnPurchase ( toBuyId ) {
33
35
this . requestProposals ( )
36
+ this . unsubscribeProposals ( toBuyId )
34
37
}
35
38
waitForProposals ( ) {
36
39
this . data = this . data . set ( 'proposals' , new Map ( ) )
@@ -60,7 +63,7 @@ export default Engine => class Proposal extends Engine {
60
63
}
61
64
} )
62
65
}
63
- unsubscribeProposals ( ) {
66
+ unsubscribeProposals ( toBuyId ) {
64
67
if ( ! this . data . has ( 'proposals' ) ) {
65
68
return
66
69
}
@@ -70,7 +73,11 @@ export default Engine => class Proposal extends Engine {
70
73
this . data = this . data . set ( 'proposals' , new Map ( ) )
71
74
72
75
proposals . forEach ( proposal => {
73
- const { uuid : id } = proposal
76
+ const { uuid : id , id : streamId } = proposal
77
+
78
+ if ( toBuyId === streamId ) {
79
+ return
80
+ }
74
81
75
82
this . data = this . data . setIn ( [ 'forgetProposals' , id ] , true )
76
83
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ let delayIndex = 0
4
4
5
5
export default Engine => class Purchase extends Engine {
6
6
purchase ( contractType ) {
7
- const toBuy = this . selectProposal ( contractType )
7
+ const { id , askPrice } = this . selectProposal ( contractType )
8
8
9
9
this . ongoingPurchase = true
10
10
11
- return recoverFromError ( ( ) => this . api . buyContract ( toBuy . id , toBuy . ask_price ) ,
11
+ return recoverFromError ( ( ) => this . api . buyContract ( id , askPrice ) ,
12
12
( errorCode , makeDelay ) => {
13
13
// if disconnected no need to resubscription (handled by live-api)
14
14
if ( errorCode !== 'DisconnectError' ) {
@@ -19,11 +19,11 @@ export default Engine => class Purchase extends Engine {
19
19
. then ( ( ) => makeDelay ( ) . then ( ( ) => this . observer . emit ( 'REVERT' , 'before' ) ) )
20
20
} , [ 'PriceMoved' ] , delayIndex ++ )
21
21
. then ( r => {
22
- delayIndex = 0
23
- this . broadcastPurchase ( r . buy , contractType )
24
22
this . subscribeToOpenContract ( r . buy . contract_id )
25
- this . renewProposalsOnPurchase ( )
26
23
this . signal ( 'purchase' )
24
+ delayIndex = 0
25
+ this . broadcastPurchase ( r . buy , contractType )
26
+ this . renewProposalsOnPurchase ( id )
27
27
} )
28
28
}
29
29
}
You can’t perform that action at this time.
0 commit comments