Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oskar/fix_position_removePositionById #129

Merged
merged 4 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/javascript/app/Stores/Modules/Contract/contract-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export default class ContractStore extends BaseStore {
@observable is_replay_static_chart = false;

// ---- Normal properties ---
forget_id;
chart_type = 'mountain';
is_from_positions = false;
is_ongoing_contract = false;
Expand All @@ -62,7 +61,6 @@ export default class ContractStore extends BaseStore {
// -------------------
@action.bound
drawChart(SmartChartStore, contract_info) {
this.forget_id = contract_info.id;
const { date_start } = contract_info;
const end_time = getEndTime(contract_info);

Expand Down Expand Up @@ -148,7 +146,6 @@ export default class ContractStore extends BaseStore {

@action.bound
onUnmountReplay() {
this.forget_id = null;
this.replay_contract_id = null;
this.digits_info = {};
this.is_ongoing_contract = false;
Expand Down Expand Up @@ -176,7 +173,6 @@ export default class ContractStore extends BaseStore {
this.contract_info = {};
this.digits_info = {};
this.error_message = '';
this.forget_id = null;
this.has_error = false;
this.is_sell_requested = false;
this.is_from_positions = false;
Expand Down Expand Up @@ -212,7 +208,6 @@ export default class ContractStore extends BaseStore {
}
if (+response.proposal_open_contract.contract_id !== +this.replay_contract_id) return;

this.forget_id = response.proposal_open_contract.id;
this.replay_info = response.proposal_open_contract;

// Add indicative status for contract
Expand Down Expand Up @@ -335,10 +330,6 @@ export default class ContractStore extends BaseStore {
SmartChartStore.updateGranularity(granularity);
}

forgetProposalOpenContract() {
WS.forget('proposal_open_contract', this.updateProposal, { id: this.forget_id });
}

waitForChartListener = (SmartChartStore) => {
// TODO: Refactor, timeout interval is required for completed contracts.
// There is an issue when we receive the proposal_open_contract response
Expand Down
12 changes: 6 additions & 6 deletions src/javascript/app/Stores/Modules/Portfolio/portfolio-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ export default class PortfolioStore extends BaseStore {

@action.bound
removePositionById(contract_id) {
const is_contract_mode = this.root_store.modules.smart_chart.is_contract_mode;
let i = this.getPositionIndexById(contract_id);
// check if position to be removed is out of range from the maximum amount rendered in drawer
if (this.positions.length > 4) i += 1;
this.positions.splice(i, 1);
const { is_contract_mode } = this.root_store.modules.smart_chart;
const contract_idx = this.getPositionIndexById(contract_id);

this.positions.splice(contract_idx, 1);

// check if contract is in view in contract_mode before removing contract details from chart
if (is_contract_mode && (this.root_store.modules.contract.contract_id === contract_id)) {
if (is_contract_mode && (+this.root_store.modules.contract.contract_id === +contract_id)) {
this.root_store.modules.contract.onCloseContract();
this.root_store.modules.trade.requestProposal();
}
Expand Down