Skip to content

Commit

Permalink
Apply snapshot instead of reloading table in SiteStatsInsightsTableVi…
Browse files Browse the repository at this point in the history
…ewController
  • Loading branch information
staskus committed Feb 12, 2024
1 parent 984d698 commit 4ec49cd
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ class SiteStatsInsightsTableViewController: SiteStatsBaseTableViewController, St
private let analyticsTracker = BottomScrollAnalyticsTracker()

private lazy var tableHandler: ImmuTableViewHandler = {
return ImmuTableViewHandler(takeOver: self, with: analyticsTracker)
let handler = ImmuTableViewHandler(takeOver: self, with: analyticsTracker)
handler.automaticallyReloadTableView = false
tableView.dataSource = dataSource
tableView.delegate = self // TODO
return handler
}()

private lazy var dataSource: StatsInsightsDataSource = {
return StatsInsightsDataSource(tableView: tableView) { tableView, indexPath, item in
let row = item.immuTableRow
let cell = tableView.dequeueReusableCell(withIdentifier: row.reusableIdentifier, for: indexPath)
row.configureCell(cell)
return cell
}
}()

// MARK: - View
Expand Down Expand Up @@ -166,7 +179,7 @@ private extension SiteStatsInsightsTableViewController {
return
}

tableHandler.viewModel = viewModel.tableViewModel()
dataSource.apply(viewModel.tableViewSnapshot(), animatingDifferences: false)

if viewModel.fetchingFailed() {
displayFailureViewIfNecessary()
Expand Down

0 comments on commit 4ec49cd

Please sign in to comment.