Skip to content

Commit

Permalink
Fixed bug Stats: Year/Month/Week Stats are empty after navigating #21862
Browse files Browse the repository at this point in the history
 (#21970)

Co-authored-by: rohitsar123
  • Loading branch information
staskus committed Nov 23, 2023
2 parents 84262b4 + 988f137 commit 4b7e49d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ class SiteStatsPeriodTableViewController: UITableViewController, StoryboardLoada
if oldValue == nil {
initViewModel()
} else {
// If the oldValue is equal to the new value the overview cache is cleaned
// This might happen only when a new date has been injected from the dashboard,
// and the app will enter the foreground state.
refreshData(resetOverviewCache: oldValue == selectedPeriod)
refreshData()
}
}
}
Expand Down Expand Up @@ -81,7 +78,7 @@ class SiteStatsPeriodTableViewController: UITableViewController, StoryboardLoada
return
}
addViewModelListeners()
viewModel?.refreshPeriodOverviewData(withDate: date, forPeriod: period, resetOverviewCache: false)
viewModel?.refreshPeriodOverviewData(withDate: date, forPeriod: period)
}
}

Expand Down Expand Up @@ -179,15 +176,15 @@ private extension SiteStatsPeriodTableViewController {
refreshData()
}

func refreshData(resetOverviewCache: Bool = false) {
func refreshData() {
guard let selectedDate = selectedDate,
let selectedPeriod = selectedPeriod,
viewIsVisible() else {
refreshControl?.endRefreshing()
return
}
addViewModelListeners()
viewModel?.refreshPeriodOverviewData(withDate: selectedDate, forPeriod: selectedPeriod, resetOverviewCache: resetOverviewCache)
viewModel?.refreshPeriodOverviewData(withDate: selectedDate, forPeriod: selectedPeriod)
}

func applyTableUpdates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,7 @@ class SiteStatsPeriodViewModel: Observable {

// MARK: - Refresh Data

func refreshPeriodOverviewData(withDate date: Date, forPeriod period: StatsPeriodUnit, resetOverviewCache: Bool = false) {
if resetOverviewCache {
mostRecentChartData = nil
}

func refreshPeriodOverviewData(withDate date: Date, forPeriod period: StatsPeriodUnit) {
selectedDate = date
lastRequestedPeriod = period
ActionDispatcher.dispatch(PeriodAction.refreshPeriodOverviewData(date: date, period: period, forceRefresh: true))
Expand Down

0 comments on commit 4b7e49d

Please sign in to comment.