Skip to content

RS Post Settings: Add author search to author dialog#22689

Open
nbradbury wants to merge 26 commits intotrunkfrom
feature/rsposts-author-search
Open

RS Post Settings: Add author search to author dialog#22689
nbradbury wants to merge 26 commits intotrunkfrom
feature/rsposts-author-search

Conversation

@nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Mar 13, 2026

Description

Adds author search functionality to the author selection dialog on the RS Post Settings screen.

  • Author search: Debounced search field in the author dialog with loading indicator and "no results" state. Clears search state on dialog dismiss so reopening shows a fresh list.
  • Code simplification: Removed redundant null checks, deduplicated the AUTHORS_PER_PAGE constant (single source of truth in PostRsRestClient), replaced itemsIndexed with items where the index was unused, and removed redundant state clearing.

Note: I noticed while testing this that if you select another author then rotate the device, the selection is lost. I'd fix that here but it also happens with the other post settings dialogs so I'll fix it separately.

Testing instructions

Author search:

  1. Open a post's RS Post Settings screen
  2. Tap the Author field to open the author dialog
  3. Type a search query (3+ characters) in the search field
  • Verify a loading spinner appears while searching
  • Verify matching authors are shown, or "No results found" for no matches
  1. Clear the search field
  • Verify the full author list reloads
  1. Close the dialog and reopen it
  • Verify the search field is empty and the full author list is shown
author.mp4

nbradbury and others added 21 commits March 12, 2026 06:58
Replace Toast with Compose Snackbar for inline error messages with retry
actions, add pull-to-refresh support, show "Saving..." label alongside
the spinner, display "Not Set" placeholder for empty status, and improve
accessibility with content descriptions for password toggle and featured
image placeholder. Extract shared error utilities from PostRsListViewModel
into PostRsErrorUtils for reuse across both list and settings screens.
Add unit tests for PostRsSettingsViewModel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Preserve unsaved edits when refreshing post from server
- Remove unreachable snackbar when site is null (activity finishes immediately)
- Fix PullToRefreshBox content indentation
- Remove redundant offline mocks in refresh tests
- Rename misleading test name for status selection
- Add test for save-online sets isSaving

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract preserveEdits() helper to shorten refreshPost() below the
60-line detekt limit, and remove empty line after opening brace in
test class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add navigationBarsPadding to SnackbarHost so snackbars aren't
obscured by the system navigation bar. Wrap ErrorContent in a
centered Box so the error message displays in the center of the
screen instead of at the top.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fillMaxWidth and TextAlign.Center to the ErrorContent on the
term selection screen so the network error message is properly
centered horizontally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The network error snackbar shown when saving in airplane mode was
missing an actionLabel and onAction callback, so no Retry button
appeared. Add both so the user can retry saving after reconnecting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Set the snackbar action color to MaterialTheme.colorScheme.primary
so the Retry text on snackbars matches the primary color used by
the Retry button on the error empty state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…race condition

When disabling airplane mode and immediately tapping Retry, Android may not
have re-established connectivity yet, causing a spurious network error. Now
the save always proceeds to the API call, which handles network errors
naturally via its catch block using PostRsErrorUtils.friendlyErrorMessage().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use BackHandler(onBack=) instead of wrapping lambda
- Use ?.let { } ?: Modifier for conditional click modifiers
- Replace PostApiException with RuntimeException
- Inline isAuthError wrapper in PostRsListViewModel
- Remove status bar hiding to fix PTR triggering on system bar pull

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace RuntimeException with PostApiRequestException to fix
TooGenericExceptionThrown detekt violations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On self-hosted sites, a new WpApiClient was created for every API call
(5 instantiations just to open post settings). Cache self-hosted clients
in WpApiClientProvider (mirroring the existing WP.com pattern), add a
per-site client cache in PostRsRestClient, and use a lazy property in
PostRsSettingsViewModel to reuse the same client across fetch and save.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that WpApiClientProvider caches self-hosted clients, the per-site
client cache in PostRsRestClient is redundant — remove it. Also remove
the now-unused site parameters from fetchPost() and savePost() in the
ViewModel, and replace shadowed locals with simple null guards.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…eption, remove unused methods

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show hero image shimmer and placeholder rows while loading instead
of a titled app bar with a centered spinner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract shared HeroOverlay composable to deduplicate gradient
  and back button between loading skeleton and hero layout
- Inline statusResId variable
- Remove unreachable site null guards in ViewModel
- Remove extra blank line in WpApiClientProvider

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a debounced search field to the author selection dialog, matching
the existing pattern used for category/tag term search. Also fixes
author selection from index-based to ID-based to prevent incorrect
selection when the list changes during search or load-more.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace itemsIndexed with items in AuthorDialog since the index was
unused, and consolidate AUTHORS_PER_PAGE to a single constant in
PostRsRestClient.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reset the search query, search flag, and cached author list on
dismiss so reopening the dialog shows a fresh state instead of
stale search results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The authorSearchQuery and isSearchingAuthors fields are already
reset by onDismissDialog(), so clearing them again on open is
unnecessary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dangermattic
Copy link
Collaborator

dangermattic commented Mar 13, 2026

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@nbradbury nbradbury changed the base branch from trunk to feature/rsposts-settings-performance March 13, 2026 17:16
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 13, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22689-ff47df2
Build Number1487
Application IDorg.wordpress.android.prealpha
Commitff47df2
Installation URL4ua6kfqkr7m18
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 13, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22689-ff47df2
Build Number1487
Application IDcom.jetpack.android.prealpha
Commitff47df2
Installation URL5h4q2v3m086e0
Note: Google Login is not supported on these builds.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 6.89655% with 135 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.47%. Comparing base (0a8f644) to head (ff47df2).

Files with missing lines Patch % Lines
...android/ui/postsrs/screens/PostRsSettingsScreen.kt 0.00% 90 Missing ⚠️
...ress/android/ui/postsrs/PostRsSettingsViewModel.kt 15.09% 44 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22689      +/-   ##
==========================================
- Coverage   37.50%   37.47%   -0.04%     
==========================================
  Files        2298     2298              
  Lines      120741   120866     +125     
  Branches    16531    16545      +14     
==========================================
+ Hits        45288    45297       +9     
- Misses      71781    71896     +115     
- Partials     3672     3673       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from feature/rsposts-settings-performance to trunk March 16, 2026 14:59
nbradbury and others added 3 commits March 17, 2026 08:27
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reset nextAuthorPageParams and canLoadMoreAuthors when the author
dialog is dismissed to prevent stale pagination state. Show a
snackbar when author search fails, consistent with other error
handling in the ViewModel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nbradbury nbradbury marked this pull request as ready for review March 17, 2026 13:40
@nbradbury nbradbury requested a review from adalpari March 17, 2026 13:40
@adalpari
Copy link
Contributor

Found a couple of UI issues:

  1. If there are no results, I can still click OK
  2. When I open the dialog again, I see the old search
Screen_recording_20260317_165046.mp4

nbradbury and others added 2 commits March 17, 2026 12:10
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nbradbury
Copy link
Contributor Author

Found a couple of UI issues:

@adalpari Oof, I know that second one was resolved before, so I must've had a merge conflict and chose the wrong one. Both are fixed now.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants