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

People: Fixes RoleSelect issue with localStorage cleared #3542

Merged
merged 1 commit into from
Feb 24, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions client/my-sites/people/role-select/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import sitesList from 'lib/sites-list';
/**
* Module variables
*/
const debug = debugFactory( 'calypso:role-select' );
const debug = debugFactory( 'calypso:my-sites:people:role-select' );
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

const sites = sitesList();

export default React.createClass( {
Expand All @@ -42,6 +42,8 @@ export default React.createClass( {
},

componentWillReceiveProps( nextProps ) {
const siteId = nextProps.siteId || this.props.siteId;
this.fetchRoles( siteId );
this.refreshRoles( nextProps );
},

Expand Down Expand Up @@ -77,17 +79,19 @@ export default React.createClass( {
}
},

fetchRoles() {
const siteId = this.props.siteId || null;
fetchRoles( siteId = this.props.siteId ) {
if ( ! siteId ) {
debug( 'siteId not set' );
return;
}

if ( RolesStore.getRoles( siteId ).length ) {
if ( Object.keys( RolesStore.getRoles( siteId ) ).length ) {
debug( 'initial fetch not necessary' );
return;
}

debug( 'Fetching roles for ' + siteId );

// defer fetch requests to avoid dispatcher conflicts
setTimeout( function() {
const fetching = RolesStore.isFetching( siteId );
Expand Down