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

Selectors: Add areAllSitesSingleUser #13123

Merged
merged 2 commits into from
Apr 14, 2017

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Apr 14, 2017

Returns true if every site of the current user is a single user site.

Needed for #13121 and #13094.

Not used in code yet.

@matticbot
Copy link
Contributor

@ockham ockham force-pushed the add/selectors/are-all-sites-single-user branch from bcd72ba to 8f81602 Compare April 14, 2017 20:02
@matticbot matticbot added [Size] M Medium sized issue and removed [Size] S Small sized issue labels Apr 14, 2017
@ockham ockham added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Apr 14, 2017
@ockham ockham requested review from mcsf, ehg and gwwar April 14, 2017 20:03
* @param {Object} state Global state tree
* @return {Boolean} True if all sites are single user sites
*/
export default function areAllSitesSingleUser( state ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth memoizing with createSelector

*/
export default function areAllSitesSingleUser( state ) {
const siteIds = Object.keys( state.sites.items );
return siteIds && siteIds.every( ( siteId ) => isSingleUserSite( state, siteId ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe an empty array will be true here

Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Good to 🚢 after you verify if that's the desired behavior for initial state.

@ockham
Copy link
Contributor Author

ockham commented Apr 14, 2017

AFAICS, this is only used by the post editor to route to /posts/my instead of /posts. For a user that doesn't have any sites at all, the entire My Sites section is unavailable, so it should be irrelevant.

@ockham ockham force-pushed the add/selectors/are-all-sites-single-user branch from 61d8aa8 to 2e7f87a Compare April 14, 2017 21:23
@ockham ockham merged commit 22b043e into master Apr 14, 2017
@ockham ockham deleted the add/selectors/are-all-sites-single-user branch April 14, 2017 21:28
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework [Size] M Medium sized issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants