Skip to content

Commit

Permalink
Stats Insights: Optimize table view updates by integrating diffable d…
Browse files Browse the repository at this point in the history
…ata source (#22592)
  • Loading branch information
staskus committed Apr 8, 2024
2 parents 393ab0c + 3c87ba7 commit 901c7b3
Show file tree
Hide file tree
Showing 19 changed files with 498 additions and 298 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def gravatar
end

def wordpress_kit
pod 'WordPressKit', '~> 16.0.0'
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: ''
# pod 'WordPressKit', '~> 16.0.0'
pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', commit: '7343890fb3b1b6a7be29cddb9194bf88a71a4a2a'
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', branch: ''
# pod 'WordPressKit', git: 'https://github.com/wordpress-mobile/WordPressKit-iOS.git', tag: ''
# pod 'WordPressKit', path: '../WordPressKit-iOS'
Expand Down
11 changes: 8 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DEPENDENCIES:
- SwiftLint (= 0.54.0)
- WordPress-Editor-iOS (~> 1.19.11)
- WordPressAuthenticator (>= 9.0.6, ~> 9.0)
- WordPressKit (~> 16.0.0)
- WordPressKit (from `https://github.com/wordpress-mobile/WordPressKit-iOS.git`, commit `7343890fb3b1b6a7be29cddb9194bf88a71a4a2a`)
- WordPressShared (>= 2.3.1, ~> 2.3)
- WordPressUI (~> 1.16)
- ZendeskSupportSDK (= 5.3.0)
Expand Down Expand Up @@ -159,7 +159,6 @@ SPEC REPOS:
- SVProgressHUD
- SwiftLint
- UIDeviceIdentifier
- WordPressKit
- WordPressShared
- WordPressUI
- wpxmlrpc
Expand All @@ -178,11 +177,17 @@ EXTERNAL SOURCES:
:tag: 0.2.0
Gutenberg:
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.116.0.podspec
WordPressKit:
:commit: 7343890fb3b1b6a7be29cddb9194bf88a71a4a2a
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

CHECKOUT OPTIONS:
FSInteractiveMap:
:git: https://github.com/wordpress-mobile/FSInteractiveMap.git
:tag: 0.2.0
WordPressKit:
:commit: 7343890fb3b1b6a7be29cddb9194bf88a71a4a2a
:git: https://github.com/wordpress-mobile/WordPressKit-iOS.git

SPEC CHECKSUMS:
Alamofire: 02b772c9910e8eba1a079227c32fbd9e46c90a24
Expand Down Expand Up @@ -229,6 +234,6 @@ SPEC CHECKSUMS:
ZendeskSupportSDK: 3a8e508ab1d9dd22dc038df6c694466414e037ba
ZIPFoundation: d170fa8e270b2a32bef9dcdcabff5b8f1a5deced

PODFILE CHECKSUM: cff152d6fd3b6c78aa23f95c2449c871b1248397
PODFILE CHECKSUM: 6e74065cba7463e109be714fa4648c038642c5bf

COCOAPODS: 1.15.2
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
24.7
-----

* [*] [Jetpack-only] Stats: Optimized the Insights tab to enhance loading and scrolling performance. [#22592]


24.6
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class SiteStatsImmuTableRows {
periodEndDate: Date? = nil,
statsLineChartViewDelegate: StatsLineChartViewDelegate?,
siteStatsInsightsDelegate: SiteStatsInsightsDelegate?,
viewsAndVisitorsDelegate: StatsInsightsViewsAndVisitorsDelegate?) -> [ImmuTableRow] {
var tableRows = [ImmuTableRow]()
viewsAndVisitorsDelegate: StatsInsightsViewsAndVisitorsDelegate?) -> [any StatsHashableImmuTableRow] {
var tableRows = [any StatsHashableImmuTableRow]()

let viewsData = SiteStatsInsightsViewModel.intervalData(statsSummaryTimeIntervalData, summaryType: .views, periodEndDate: periodEndDate)
let viewsSegmentData = StatsSegmentedControlData(segmentTitle: StatSection.periodOverviewViews.tabTitle,
Expand Down Expand Up @@ -72,7 +72,8 @@ class SiteStatsImmuTableRows {
statsLineChartViewDelegate: statsLineChartViewDelegate,
siteStatsInsightsDelegate: siteStatsInsightsDelegate,
viewsAndVisitorsDelegate: viewsAndVisitorsDelegate,
xAxisDates: xAxisDates
xAxisDates: xAxisDates,
statSection: .insightsViewsVisitors
)
tableRows.append(row)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class SiteStatsInsightsTableViewController: SiteStatsBaseTableViewController, St

private let analyticsTracker = BottomScrollAnalyticsTracker()

private lazy var tableHandler: ImmuTableViewHandler = {
return ImmuTableViewHandler(takeOver: self, with: analyticsTracker)
private lazy var tableHandler: ImmuTableDiffableViewHandler = {
return ImmuTableDiffableViewHandler(takeOver: self, with: analyticsTracker)
}()

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

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

if viewModel.fetchingFailed() {
displayFailureViewIfNecessary()
Expand All @@ -200,8 +200,11 @@ private extension SiteStatsInsightsTableViewController {
}

func applyTableUpdates() {
tableView.performBatchUpdates({
})
guard let viewModel = viewModel else {
return
}

tableHandler.diffableDataSource.apply(viewModel.tableViewSnapshot(), animatingDifferences: false)
}

func clearExpandedRows() {
Expand Down

0 comments on commit 901c7b3

Please sign in to comment.