Skip to content

Extract DataViewPaginatedResponse#24592

Merged
kean merged 12 commits intofeature/jetpack-activity-logsfrom
task/activity-logs-swiftui
Jun 19, 2025
Merged

Extract DataViewPaginatedResponse#24592
kean merged 12 commits intofeature/jetpack-activity-logsfrom
task/activity-logs-swiftui

Conversation

@kean
Copy link
Contributor

@kean kean commented Jun 16, 2025

This PR is a prerequisite for reimplementing "Jetpack Activity Logs" using "DataViews".

Summary

  • Extracted DataViewPaginatedResponse for managing paginated data loading
  • Implemented DataViewPaginatedForEach SwiftUI component for displaying paginated lists
  • Refactored subscribers feature to use the new types
  • Added test coverage for the pagination functionality
  • Fix an issue with deleteItem not updating count (should decrement by one)
  • Rename LoadMoreFooterView to make it clear it's part of the "DataView" infrastructure

Test Plan

  • Verify subscribers list loads and paginates correctly
  • Test error states and retry functionality in subscribers
  • Confirm footer loading/error states display properly
  • Run existing subscribers tests to ensure no regressions
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-16.at.14.44.08.mov

Note: nearly all code was generated with Claude Code (after many-many prompts)

@kean kean added this to the 26.0 milestone Jun 16, 2025
@kean kean requested a review from crazytonyli June 16, 2025 20:23
@kean kean added the General label Jun 16, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented Jun 16, 2025

2 Warnings
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 26.0. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@kean kean force-pushed the task/activity-logs-swiftui branch from 3219b88 to 9dd6c51 Compare June 16, 2025 20:32
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 16, 2025

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number27883
VersionPR #24592
Bundle IDcom.jetpack.alpha
Commitf99f95c
Installation URL35vrmjvi9m3ng
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 16, 2025

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number27883
VersionPR #24592
Bundle IDorg.wordpress.alpha
Commitf99f95c
Installation URL7frij6e7ks93g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Base automatically changed from task/ff-dataviews to trunk June 17, 2025 04:39
///
/// - Parameter row: The row that appeared.
public func onRowAppeared(_ row: Element) {
guard items.suffix(16).contains(where: { $0.id == row.id }) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the suffix argument be 10 (according to the documentation), instead of 16?

}

func getSubscribersService() throws -> SubscribersServiceRemote {
func maketSubscribersService() throws -> SubscribersServiceRemote {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func maketSubscribersService() throws -> SubscribersServiceRemote {
func makeSubscribersService() throws -> SubscribersServiceRemote {

/// - response: The paginated response handler that manages the data.
/// - content: A view builder that creates the content for each item.
public init(
response: Response,
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, the query is built into the Response instance. When you change the query (like sorting or filtering by a different property), you create a new Response instance and thus use a different DataViewPaginatedForEach view. If that's the case, the list would start from the first page after changing the query, since previously loaded data is lost (no matter how far the user has scrolled), which may not be a good UX?

It's not something we need to solve now, but I thought it might be something we should consider further down the road.

kean added 11 commits June 17, 2025 15:31
- Rename PaginatedResponse to DataViewPaginatedResponse for better naming consistency
- Move files from Pagination to DataView directory
- Update documentation to focus on UI usage with PaginatedForEach
- Add comprehensive unit tests for DataViewPaginatedResponse
- Update deleteItem method to properly decrement total when removing items
- Update tests to verify total count is correctly maintained after deletion
Replace custom SubscribersPaginatedResponse with generic DataViewPaginatedResponse system. Add notification-based subscriber deletion updates and improve pagination handling with DataViewPaginatedForEach component.
…sion

- Rename getSubscribersService() to maketSubscribersService() to better reflect factory pattern
- Move deleteSubscriber extension from SubsriberDetailsViewModel to dedicated SubscribersServiceRemote+Extensions file
- Update all callers to use the renamed method
@kean kean force-pushed the task/activity-logs-swiftui branch from d464cb1 to c07e5bc Compare June 17, 2025 19:55
@kean kean requested a review from crazytonyli June 18, 2025 16:38
@kean
Copy link
Contributor Author

kean commented Jun 18, 2025

Something is wrong with this PR. It keeps marking my replies as "Pending".

I addressed the feedback, and here was the reply about the filters UI/UX:

It might be the only reasonable option, and it matches the behavior on the web.

The primary use-case would be the following:

  • You open "Subscribers"
  • You want to see only your paid subscribers, so you select the filter
  • We re-fetch the data
  • It's less likely that you would scroll first and only then start filtering.

I'm open to suggestions how to improve this. I initially considered creating an in-memory store similar to the one for plugins, but I decided it wasn't needed as the current UI/UX with just an in-memory cache of the current request with a combination of fast response work really well. We should be able to use it for the majority of features.

@sonarqubecloud
Copy link

@kean kean changed the base branch from trunk to feature/jetpack-activity-logs June 19, 2025 12:18
@kean kean merged commit e61dbf3 into feature/jetpack-activity-logs Jun 19, 2025
32 of 34 checks passed
@kean kean deleted the task/activity-logs-swiftui branch June 19, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants