Skip to content

Commit

Permalink
Merge pull request #42 from OskarAhl/oskar/pass_start_epoch_on_open
Browse files Browse the repository at this point in the history
oskar/pass_start_epoch_on_open
  • Loading branch information
negarn committed May 14, 2019
2 parents df1d429 + e35cf8c commit 84bf30c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/javascript/app/Modules/SmartChart/Containers/smart-chart.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Chart extends React.Component {
null : this.bottomWidgets }
chartControlsWidgets={this.props.is_contract_mode ? null : this.chartControlsWidgets}
chartType={this.props.chart_type}
endEpoch={this.props.range.end_epoch}
endEpoch={this.props.end_epoch}
id={this.props.chart_id}
isMobile={this.props.is_mobile}
granularity={this.props.granularity}
Expand All @@ -54,7 +54,7 @@ class Chart extends React.Component {
requestSubscribe={this.props.wsSubscribe}
settings={this.props.settings}
showLastDigitStats={this.props.should_show_last_digit_stats}
startEpoch={this.props.range.start_epoch}
startEpoch={this.props.start_epoch}
scrollToEpoch={this.props.scroll_to_epoch}
scrollToEpochOffset={this.props.scroll_to_offset}
symbol={this.props.symbol}
Expand Down Expand Up @@ -94,7 +94,6 @@ Chart.propTypes = {
onMount : PropTypes.func,
onSymbolChange : PropTypes.func,
onUnmount : PropTypes.func,
range : PropTypes.object,
scroll_to_epoch : PropTypes.number,
scroll_to_epoch_offset : PropTypes.number,
settings : PropTypes.object,
Expand All @@ -117,18 +116,19 @@ export default connect(
is_socket_opened : common.is_socket_opened,
barriers_array : modules.smart_chart.barriers_array,
chart_type : modules.smart_chart.chart_type,
is_contract_mode : modules.smart_chart.is_contract_mode,
end_epoch : modules.smart_chart.end_epoch,
exportLayout : modules.smart_chart.exportLayout,
granularity : modules.smart_chart.granularity,
is_contract_mode : modules.smart_chart.is_contract_mode,
is_title_enabled : modules.smart_chart.is_title_enabled,
markers_array : modules.smart_chart.markers_array,
onMount : modules.smart_chart.onMount,
onUnmount : modules.smart_chart.onUnmount,
range : modules.smart_chart.range,
settings : modules.smart_chart.settings,
should_clear_chart : modules.smart_chart.should_clear_chart,
should_export_layout: modules.smart_chart.should_export_layout,
should_import_layout: modules.smart_chart.should_import_layout,
start_epoch : modules.smart_chart.start_epoch,
trade_chart_layout : modules.smart_chart.trade_chart_layout,
updateChartType : modules.smart_chart.updateChartType,
updateGranularity : modules.smart_chart.updateGranularity,
Expand Down
15 changes: 9 additions & 6 deletions src/javascript/app/Stores/Modules/Contract/contract-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@ export default class ContractStore extends BaseStore {
@action.bound
drawChart(SmartChartStore, contract_info) {
this.forget_id = contract_info.id;
const end_time = getEndTime(contract_info);
const should_update_chart_type = !contract_info.tick_count && !this.is_granularity_set;
const { date_start } = contract_info;
const end_time = getEndTime(contract_info);
const should_update_chart_type = (!contract_info.tick_count && !this.is_granularity_set);
SmartChartStore.setContractStart(date_start);
if (end_time) {
SmartChartStore.setRange(contract_info.date_start, end_time);
SmartChartStore.setContractEnd(end_time);
if (should_update_chart_type) {
this.handleChartType(SmartChartStore, contract_info.date_start, end_time);
this.handleChartType(SmartChartStore, date_start, end_time);
} else {
SmartChartStore.updateGranularity(0);
SmartChartStore.updateChartType('mountain');
Expand All @@ -73,9 +76,9 @@ export default class ContractStore extends BaseStore {
this.is_left_epoch_set = true;
SmartChartStore.setChartView(contract_info.purchase_time);
} else if (should_update_chart_type) {
this.handleChartType(SmartChartStore, contract_info.date_start, null);
this.handleChartType(SmartChartStore, date_start, null);
} else if (this.is_granularity_set) {
if (getChartType(contract_info.date_start, null) !== this.chart_type) {
if (getChartType(date_start, null) !== this.chart_type) {
this.is_granularity_set = false;
}
}
Expand Down
19 changes: 8 additions & 11 deletions src/javascript/app/Stores/Modules/SmartChart/smart-chart-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ export default class SmartChartStore extends BaseStore {
@observable is_contract_mode = false;
@observable is_title_enabled = true;

@observable range = observable.object({
start_epoch: null,
end_epoch : null,
});
@observable start_epoch;
@observable end_epoch;

@observable scroll_to_left_epoch = null;
@observable scroll_to_left_epoch_offset = 0;
Expand Down Expand Up @@ -61,9 +59,10 @@ export default class SmartChartStore extends BaseStore {
cleanupContractChartView() {
this.removeBarriers();
this.removeMarkers();
this.removeRange();
this.resetScrollToLeft();
this.setContractMode(false);
this.setContractStart(null);
this.setContractEnd(null);
}

@action.bound
Expand Down Expand Up @@ -101,15 +100,13 @@ export default class SmartChartStore extends BaseStore {

// --------- All Contracts ---------
@action.bound
setRange(start, end) {
this.range.start_epoch = start;
this.range.end_epoch = end;
setContractStart(start) {
this.start_epoch = start;
}

@action.bound
removeRange() {
this.range.start_epoch = null;
this.range.end_epoch = null;
setContractEnd(end) {
this.end_epoch = end;
}

// ---------- Barriers ----------
Expand Down

0 comments on commit 84bf30c

Please sign in to comment.