Skip to content

Commit

Permalink
Allow Sharing buttons to load on empty cache (#11754)
Browse files Browse the repository at this point in the history
None of the props are actually required, and all queries can happen one
we do have a site ID.

See
#11724 (comment)
38
  • Loading branch information
obenland authored Mar 3, 2017
1 parent 6fd91a1 commit 5aea1f8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions client/my-sites/sharing/buttons/buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import React, { Component, PropTypes } from 'react';
import { flowRight } from 'lodash';
import { flowRight, values } from 'lodash';
import { connect } from 'react-redux';
import { localize } from 'i18n-calypso';

Expand Down Expand Up @@ -32,15 +32,15 @@ class SharingButtons extends Component {

static propTypes = {
buttons: PropTypes.array,
isSaving: PropTypes.bool.isRequired,
isSaveSettingsSuccessful: PropTypes.bool.isRequired,
isSaveButtonsSuccessful: PropTypes.bool.isRequired,
postTypes: PropTypes.object,
markSaved: PropTypes.func.isRequired,
markChanged: PropTypes.func.isRequired,
isSaving: PropTypes.bool,
isSaveSettingsSuccessful: PropTypes.bool,
isSaveButtonsSuccessful: PropTypes.bool,
postTypes: PropTypes.array,
markSaved: PropTypes.func,
markChanged: PropTypes.func,
settings: PropTypes.object,
siteId: PropTypes.number.isRequired,
translate: PropTypes.func.isRequired,
siteId: PropTypes.number,
translate: PropTypes.func,
};

saveChanges = event => {
Expand Down Expand Up @@ -97,7 +97,7 @@ class SharingButtons extends Component {
return (
<form onSubmit={ this.saveChanges } id="sharing-buttons" className="sharing-settings sharing-buttons">
<QuerySiteSettings siteId={ siteId } />
<QueryPostTypes siteId={ siteId } />
{ siteId && <QueryPostTypes siteId={ siteId } /> }
<QuerySharingButtons siteId={ siteId } />
<ButtonsAppearance
buttons={ updatedButtons }
Expand All @@ -107,7 +107,7 @@ class SharingButtons extends Component {
initialized={ !! buttons && !! settings }
saving={ isSaving } />
<ButtonsOptions
postTypes={ Object.values( postTypes ) }
postTypes={ postTypes }
buttons={ buttons }
values={ updatedSettings }
onChange={ this.handleChange }
Expand All @@ -122,7 +122,7 @@ const connectComponent = connect(
state => {
const siteId = getSelectedSiteId( state );
const settings = getSiteSettings( state, siteId );
const postTypes = getPostTypes( state, siteId );
const postTypes = values( getPostTypes( state, siteId ) );
const buttons = getSharingButtons( state, siteId );
const isSavingSettings = isSavingSiteSettings( state, siteId );
const isSavingButtons = isSavingSharingButtons( state, siteId );
Expand Down

0 comments on commit 5aea1f8

Please sign in to comment.