Skip to content

Commit

Permalink
Fix #18
Browse files Browse the repository at this point in the history
  • Loading branch information
aydenp committed Dec 4, 2017
1 parent 14364a8 commit fac1c0a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Bank/Views/AccountHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,17 @@ class AccountHeaderView: UIView {
setupChart()
}

var chartChangeIndex = 0
private func setupChart() {
chartChangeIndex += 1
let requiredIndex = chartChangeIndex
chart.removeAllSeries()
chartLoadingView.stopAnimating()
guard let account = account else { return }
chartLoadingView.startAnimating()
account.getBalanceHistoricalData(from: selectedRange.startDate) { (data) in
// Make sure this is for the latest fetch, by comparing the change index when we started to the current one.
if self.chartChangeIndex != requiredIndex { return }
DispatchQueue.main.async {
let series = ChartSeries(data: data.map { (x: Float($0.0.timeIntervalSinceReferenceDate), y: Float($0.1)) })
series.color = Colours.main
Expand Down

0 comments on commit fac1c0a

Please sign in to comment.