RS Post Settings: Fetch site post formats from themes API#22710
Open
RS Post Settings: Fetch site post formats from themes API#22710
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
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 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. 🚀 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>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





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: