Skip to content

Commit

Permalink
MaryiaF/fix: P/L is not getting updated when a contract is terminated… (
Browse files Browse the repository at this point in the history
#6024)

* MaryiaF/fix: P/L is not getting updated when a contract is terminated in between and contract time is finished

* MaryiaF/refactor: improve code to shorter way
  • Loading branch information
maryia-matskevich-deriv committed Jul 25, 2022
1 parent b66f1e7 commit ba50688
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions packages/bot-web-ui/src/stores/transactions-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,39 @@ 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.authorized.subscribeProposalOpenContract(contract_id, response => {
if (!response.error) {
const { proposal_open_contract } = response;
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;

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 },
});
}
}
}
});
});
}
}

1 comment on commit ba50688

@vercel
Copy link

@vercel vercel bot commented on ba50688 Jul 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.vercel.app
deriv-app.binary.sx
deriv-app-git-master.binary.sx
binary.sx

Please sign in to comment.