From 6613e2e8180e1919beb016cfdbd7075c14191458 Mon Sep 17 00:00:00 2001 From: Farrah Mae Ochoa <82315152+farrah-deriv@users.noreply.github.com> Date: Tue, 26 Jul 2022 11:02:20 +0400 Subject: [PATCH] =?UTF-8?q?Revert=20"MaryiaF/fix:=20P/L=20is=20not=20getti?= =?UTF-8?q?ng=20updated=20when=20a=20contract=20is=20terminated=E2=80=A6?= =?UTF-8?q?=20(#6024)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ba506880a588f34b911c9acf85829975b1c48f57. --- .../src/stores/transactions-store.js | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/packages/bot-web-ui/src/stores/transactions-store.js b/packages/bot-web-ui/src/stores/transactions-store.js index 1d01bfc79f49..765d0c0197c7 100644 --- a/packages/bot-web-ui/src/stores/transactions-store.js +++ b/packages/bot-web-ui/src/stores/transactions-store.js @@ -174,39 +174,35 @@ export default class TransactionsStore { recoverPendingContractsById(contract_id) { const { ws } = this.root_store; - const client = ws.core?.client; - const token = client?.account[client?.loginid]?.token; - ws.send(JSON.stringify({ authorize: token })).then(() => { - ws.send({ proposal_open_contract: 1, contract_id }).then(response => { - if (!response.error) { - const { proposal_open_contract } = response; + ws.authorized.subscribeProposalOpenContract(contract_id, response => { + if (!response.error) { + const { proposal_open_contract } = response; - const { contract_info } = this.root_store.summary_card; + const { contract_info } = this.root_store.summary_card; - if (proposal_open_contract.contract_id === contract_info?.contract_id) return; + if (proposal_open_contract.contract_id === contract_info?.contract_id) return; - this.onBotContractEvent(proposal_open_contract); + this.onBotContractEvent(proposal_open_contract); - if (!this.recovered_transactions.includes(proposal_open_contract.contract_id)) { - this.recovered_transactions.push(proposal_open_contract.contract_id); - } + if (!this.recovered_transactions.includes(proposal_open_contract.contract_id)) { + this.recovered_transactions.push(proposal_open_contract.contract_id); + } - if ( - !this.recovered_completed_transactions.includes(proposal_open_contract.contract_id) && - isEnded(proposal_open_contract) - ) { - this.recovered_completed_transactions.push(proposal_open_contract.contract_id); + if ( + !this.recovered_completed_transactions.includes(proposal_open_contract.contract_id) && + isEnded(proposal_open_contract) + ) { + this.recovered_completed_transactions.push(proposal_open_contract.contract_id); - const { currency, profit } = proposal_open_contract; + const { currency, profit } = proposal_open_contract; - this.root_store.journal.onLogSuccess({ - log_type: profit > 0 ? log_types.PROFIT : log_types.LOST, - extra: { currency, profit }, - }); - } + this.root_store.journal.onLogSuccess({ + log_type: profit > 0 ? log_types.PROFIT : log_types.LOST, + extra: { currency, profit }, + }); } - }); + } }); } }