RS Post Settings: Fetch site post formats from themes API#22710
RS Post Settings: Fetch site post formats from themes API#22710
Conversation
Generated by 🚫 Danger |
|
|
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #22710 +/- ##
==========================================
- Coverage 37.35% 37.35% -0.01%
==========================================
Files 2316 2316
Lines 123272 123347 +75
Branches 16712 16727 +15
==========================================
+ Hits 46053 46071 +18
- Misses 73520 73574 +54
- Partials 3699 3702 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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>
779cfe7 to
1fdf6df
Compare
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>
|
Claude found a possible race condition, could you verify it's ok?
|
adalpari
left a comment
There was a problem hiding this comment.
LGTM!
Just left a comment to check from Claude
Only set hasFetchedFormats on success so transient network errors don't permanently lock in defaults. Also guard against concurrent fetches by checking isLoadingFormats before launching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
That's definitely an edge case but still valid. Fixed in Allow retry when site post format fetch fails. |
|





Description
The RS post settings
FormatDialogpreviously 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:
Fallback on failure: