-
Notifications
You must be signed in to change notification settings - Fork 83
Add type filter for feed based on ap_object_type taxonomy #2510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This adds a button-based filter to the feed that allows users to filter posts by ActivityPub object type (Article, Note, etc.). Changes: - Add ap_object_type field to FeedPost interface - Add apObjectType parameter to useFeed hook with REST API integration - Create TypeFilter component using WordPress ButtonGroup - Integrate TypeFilter into feed stage with localStorage persistence - Filter buttons appear in DataViews header aligned to the right The selected filter is persisted to localStorage so it's remembered across sessions.
67a10f6 to
901a259
Compare
|
Nice! Is that something we could add to the DataView settings? |
|
I tried... will give it another 30 mins... |
Replace custom TypeFilter component with native DataViews filtering system. Changes: - Remove custom TypeFilter ButtonGroup component - Add ap_object_type as a DataView filter field with 'isAny' operator - Extract filter values from view.filters instead of separate state - Remove localStorage persistence code (DataViews handles this internally) - Taxonomy terms populate filter dropdown automatically This integrates the type filter into DataViews' native filtering UI, providing: - Consistent UX with other DataViews filters - Built-in persistence through WordPress views system - Better accessibility and keyboard navigation - Automatic filter state management
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a type filter feature to the ActivityPub feed that allows users to filter posts by object type (Article, Note, etc.) using the ap_object_type taxonomy. The filter state is persisted in localStorage and properly integrated with the WordPress REST API.
Key Changes
- Added
ap_object_typefield to TypeScript interface for feed posts - Implemented REST API integration with taxonomy filtering in the
useFeedhook - Created a new
TypeFiltercomponent using WordPress ButtonGroup for the UI
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/social-web/types.ts |
Added optional ap_object_type field to FeedPost interface |
src/social-web/hooks/use-feed.ts |
Added apObjectType parameter and REST API integration for taxonomy filtering |
src/social-web/routes/feed/stage.tsx |
Integrated TypeFilter component with localStorage persistence and taxonomy term fetching |
src/social-web/components/type-filter/index.tsx |
New component providing button-based filter UI |
build/social-web/index.js |
Minified build output |
build/social-web/index.asset.php |
Updated version hash for cache busting |
build/social-web/feed-stage.js |
Minified build output for feed stage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Might be nicer if we have some more filters in the future (single actor feeds could maybe be handled as filter too) |
|
Hm, it looks like I don't have any articles… |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
|
Are articles being associated correctly in the inbox? Did you create your test-articles manually? I can't get the selector to show up, which has me wondering if that's because I only have note posts |
|
I have added some Articles, by hand and through the inbox. |
|
Hm, I do have one article post… |
|
oh! I was looking in the wrong place |
|
@obenland I just re-tested with my blogs and it works as expected. |
Introduces a filter for ActivityPub object types in the feed-stage.js component. Fetches available object types and allows filtering posts by type, updating the feed query and UI accordingly.
Co-authored-by: Konstantin Obenland <[email protected]>
Co-authored-by: Konstantin Obenland <[email protected]>
Co-authored-by: Konstantin Obenland <[email protected]>
Use date_gmt field instead of date for reliable UTC parsing in comment timestamps. This ensures comment dates display correctly using relative time format (5m, 2h, 6d) consistent with post dates.
Reworks the ActivityPub feed-stage.js to improve filter and query param handling, including more robust support for taxonomy filters and ap_object_type. Updates the filterBy operators and render logic for the 'Type' filter, and refactors state management for view updates and feed queries.
The ap_object_type taxonomy terms are now fetched without specifying the per_page parameter, relying on the default behavior of useEntityRecords. This simplifies the code and avoids unnecessary explicit pagination.
Introduces support for filtering ActivityPub feed posts by object type. Updates feed-stage.js, feed route, and related hooks to handle object type taxonomy, and adds a new object-type field component. Also updates post type registration to include the ap_object_type parameter.
Refactors the object type filter to follow Gutenberg field patterns: - Use async `getElements` to fetch taxonomy terms (no React hooks in field) - Change to single-value filtering with `is` operator instead of array-based `isAny` - Extract first value from ap_object_type array for cleaner UX - Fix filter handling in useFeed to support both single values and arrays - Remove unused useEntityRecords hook from feed stage - Simplify field definition following @wordpress/fields architecture This provides a cleaner, radio-style selection for filtering posts by type (Article, Note, etc.) while maintaining compatibility with the taxonomy structure.
obenland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In bbfe23d I moved all of the entity stuff into the field definition, too, and refactored it to enable single type selections, I hope that's okay. I meant to provide all that stuff as feedback but it got to be a lot and pretty intricate.
The main missing thing is making these term names more accessible. Article and Note are technical terms (we literally save what activities send in their type), and not necessarily the best way to describe what we're trying to convey. I'm also not sure they're translated or translatable?
Co-authored-by: Konstantin Obenland <[email protected]>
Filter to only Note and Article types and display them as "Short form" and "Long form" for better user comprehension. Also adds proper TypeScript typing using Term from @wordpress/core-data.
|
In b2d41d2, updated to limit the filter to notes and articles and make the labels translatable. I'm not sure "Short form" and "Long form" are the best labels, happy for us to change those. It doesn't seem to be easily possible to not add the filter when there's only one term. |
|
I am not a fan of limiting the types! This is a similar pattern, Mastodon used (or still uses) an what made I will think about a way to better support all kinds of Objects and to translate at least most of them. |
Updated the object type field to support all ActivityPub object types with user-friendly labels, instead of only Note and Article. The feed now displays and filters by a broader set of types, improving usability and consistency.
Set 'minimum' to 0 for integer items in the ActivityPub object type filter parameter and remove the custom sanitize_callback. This enforces non-negative values at the schema level.
|
@obenland Added some small changes to have best of both worlds. I also changed the translatable text a bit... I think "Long form" and "Short form" are no common (end-user friendly) terms... |
Summary
Adds a button-based filter to the ActivityPub feed that allows users to filter posts by object type (Article, Note, etc.) using the
ap_object_typetaxonomy.Changes
ap_object_typefield toFeedPostTypeScript interfaceapObjectTypeparameter touseFeedhook with REST API integrationTypeFiltercomponent using WordPress ButtonGroupFeatures
ap_object_typetaxonomy parameterTest plan
Screenshots