Skip to content

Commit

Permalink
request for default fiveMinBin candles first
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon committed Apr 7, 2023
1 parent fbadbf8 commit 1a82aaf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions client/webserver/site/src/js/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ export default class MarketsPage extends BasePage {
// Do not call cleanTemplates before creating the AccelerateOrderForm
this.accelerateOrderForm = new AccelerateOrderForm(page.accelerateForm, success)

// Set user's last known candle duration.
this.candleDur = State.fetchLocal(State.lastCandleDurationLK)

// Setup the register to trade button.
// TODO: Use dexsettings page?
const registerBttn = Doc.tmplElement(page.notRegistered, 'registerBttn')
Expand Down Expand Up @@ -803,7 +800,19 @@ export default class MarketsPage extends BasePage {
page.durBttnBox.appendChild(bttn)
}

// Set candle duration.
// Check if we already have the fiveMinBin candles cache, if not, request
// for it first since we use it to determine the 24hour high/low in
// this.setHighLow().
const lastCandleDur = State.fetchLocal(State.lastCandleDurationLK)
const cache = this.market?.candleCaches[fiveMinBinKey]
if (!cache && lastCandleDur !== fiveMinBinKey) {
this.candleDur = fiveMinBinKey
this.requestCandles()
}

// The fiveMinBin candles have been requested, so we can set the user's last
// known configuration now.
this.candleDur = lastCandleDur

This comment has been minimized.

Copy link
@buck54321

buck54321 Apr 12, 2023

Member

Looks like candleDurationSelected already handles this.

this.candleDurationSelected(this.candleDur)
}

Expand Down

1 comment on commit 1a82aaf

@ukane-philemon
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like candleDurationSelected already handles this.

candleDurationSelected does not know if lastCandleDur is the fiveMinBin or not, and I don't think it should care. (!cache && lastCandleDur !== fiveMinBinKey) will ensure we have the fiveMinBin sent for when lastCandleDur is something else.

Please sign in to comment.