Skip to content

Commit

Permalink
Add groundwork for marking site pressable
Browse files Browse the repository at this point in the history
  • Loading branch information
artpi committed Oct 26, 2016
1 parent 3626d47 commit e85a50c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client/state/sites/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ export function items( state = {}, action ) {
}
return state;

case 'PRESSABLE_ACTIVATE':
const originalSite = state[ action.siteId ];
if ( originalSite ) {
return Object.assign( {}, state, {
[ action.siteId ]: merge( {}, originalSite, { options: { pressable: true } } )
} );
}
return state;

case SITE_RECEIVE: {
const site = pick( action.site, VALID_SITE_KEYS );
return Object.assign( {}, state, {
Expand Down
17 changes: 17 additions & 0 deletions client/state/sites/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ export function isJetpackSite( state, siteId ) {
return site.jetpack;
}

/**
* Returns true if site is a Pressable Jetpack site, false if the site is hosted on
* WordPress.com or is a regular Jetpack, or null if the site is unknown.
*
* @param {Object} state Global state tree
* @param {Number} siteId Site ID
* @return {?Boolean} Whether site is a Pressable site
*/
export function isPressableSite( state, siteId ) {
const site = getRawSite( state, siteId );
if ( ! site ) {
return null;
}

return site.options.pressable;
}

/**
* Returns true if the site is a Jetpack site with the specified module active,
* or false if the module is not active. Returns null if the site is not known
Expand Down

0 comments on commit e85a50c

Please sign in to comment.