Skip to content
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

Use a "users" reducer combined with a "queries" sub state to map authors to users #6522

Merged
merged 1 commit into from
May 2, 2018

Conversation

youknowriad
Copy link
Contributor

@youknowriad youknowriad commented May 1, 2018

Merges into #6515

@youknowriad youknowriad self-assigned this May 1, 2018
const authors = await apiRequest( { path: '/wp/v2/users/?who=authors' } );
yield receiveAuthors( authors );
const users = await apiRequest( { path: '/wp/v2/users/?who=authors' } );
yield receiveUserQuery( 'authors', users );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hard-coding the queryID ('authors') for now but it could be generated from the query args if we want to generalize this later.

*
* @return {Array} Users list.
*/
export function getUserQueryResults( state, queryID ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This selector should probably be memoized to avoid generating an new array on each call.

@youknowriad youknowriad merged commit 1e3205b into 3010-switch-who May 2, 2018
@youknowriad youknowriad deleted the update/authors-2-users branch May 2, 2018 08:48
danielbachhuber added a commit that referenced this pull request May 2, 2018
)

* Switch `post-author` component to use `/wp/v2/users/?who=authors`

* Ensure state is always an array, properly

* Update tests for 80d0500

* Remove unused variable

* Remove unnecessary prop pass-through

* Ensure no duplicate authors are listed

* Use a "users" reducer combined with a "queries" sub state to map authors to users (#6522)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants