From e85a50c02e4a29f6ba6afc17d042dfd3b5dce6ed Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 19 Oct 2016 10:18:09 +0200 Subject: [PATCH] Add groundwork for marking site pressable --- client/state/sites/reducer.js | 9 +++++++++ client/state/sites/selectors.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/client/state/sites/reducer.js b/client/state/sites/reducer.js index f013854644811..60cf61179992f 100644 --- a/client/state/sites/reducer.js +++ b/client/state/sites/reducer.js @@ -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, { diff --git a/client/state/sites/selectors.js b/client/state/sites/selectors.js index 14a49031acaa1..e19ded1881136 100644 --- a/client/state/sites/selectors.js +++ b/client/state/sites/selectors.js @@ -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