Skip to content

RS Post Settings: Fetch site post formats from themes API#22710

Open
nbradbury wants to merge 10 commits intotrunkfrom
feature/rs-posts-post-formats
Open

RS Post Settings: Fetch site post formats from themes API#22710
nbradbury wants to merge 10 commits intotrunkfrom
feature/rs-posts-post-formats

Conversation

@nbradbury
Copy link
Contributor

@nbradbury nbradbury commented Mar 19, 2026

Description

The RS post settings FormatDialog previously hardcoded all 10 standard post formats. This PR fetches the formats actually supported by the site's active theme using the wordpress-rs themes API (themes().listWithViewContext()), falling back to the full default list if the API call fails.

Testing instructions

Theme with limited format support:

  1. View settings for a post on the "Rabbit Of Caribbeans" test site (whose active theme supports only a subset of formats)
  2. Tap the Format row to open the format dialog
  • Verify the dialog shows only the theme-supported formats plus Standard
format

Fallback on failure:

  1. Open a post, then disable network
  2. Tap the Format row
  • Verify the dialog shows the full default list of 10 formats
format2

@dangermattic
Copy link
Collaborator

dangermattic commented Mar 19, 2026

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 19, 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
Versionpr22710-1647901
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit1647901
Installation URL4f0gvup24pcdo
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 Mar 19, 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
Versionpr22710-1647901
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit1647901
Installation URL4id3srs04gdbo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 18.55670% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.35%. Comparing base (0c9a9a3) to head (1647901).

Files with missing lines Patch % Lines
...android/ui/postsrs/screens/PostRsSettingsScreen.kt 0.00% 33 Missing ⚠️
...dpress/android/ui/postsrs/data/PostRsRestClient.kt 30.23% 30 Missing ⚠️
...ress/android/ui/postsrs/PostRsSettingsViewModel.kt 11.11% 14 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22710      +/-   ##
==========================================
- Coverage   37.35%   37.35%   -0.01%     
==========================================
  Files        2316     2316              
  Lines      123272   123346      +74     
  Branches    16712    16726      +14     
==========================================
+ Hits        46053    46071      +18     
- Misses      73520    73574      +54     
- Partials     3699     3701       +2     

☔ 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.

nbradbury and others added 8 commits March 20, 2026 11:27
Fetch the active theme's supported post formats via the wordpress-rs
themes API instead of hardcoding all 10 formats. Falls back to the
full default list on failure or when the theme doesn't declare support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove redundant outer try/catch (caller already handles exceptions)
and replace mutable list + none/add pattern with distinct() for
prepending Standard format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Defer the themes API call until the user actually opens the format
picker, avoiding an unnecessary network request on every screen load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Request only THEME_SUPPORTS via filterListWithViewContext() to reduce
payload size. Fix format dialog losing its selection when site post
formats load by updating selectedIndex in a LaunchedEffect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract post format parsing into a dedicated helper that uses
nullable chaining, reducing fetchSitePostFormats to 2 return paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consolidate duplicated format knowledge into a single SLUG_TO_FORMAT map
and replace LaunchedEffect with idiomatic key() for resetting dialog state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nbradbury nbradbury force-pushed the feature/rs-posts-post-formats branch from 779cfe7 to 1fdf6df Compare March 20, 2026 15:29
nbradbury and others added 2 commits March 20, 2026 11:45
Fetch site post formats before showing the format dialog instead of
opening it immediately, eliminating visual flicker from the list
swapping. Use a hasFetchedFormats flag so the fetch runs only once
regardless of whether the result matches the defaults or fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Open the format dialog immediately on tap and display a
CircularProgressIndicator while the themes API call is in flight,
replacing the previous behavior of delaying the dialog until the
fetch completed.

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

@nbradbury nbradbury marked this pull request as ready for review March 20, 2026 16:38
@nbradbury nbradbury requested a review from adalpari March 20, 2026 16:38
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.

3 participants