diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index 35939d37769f17787a64b16b4150b1d37d60d31f..1359919cb1d8a10d67aa5da47f666dc650e6a2a7 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -171,24 +171,24 @@ class MenuBar extends React.Component { this.props.onClickSaveAsCopy(); this.props.onRequestCloseFile(); } - handleClickSeeCommunity (requestSeeCommunity) { + handleClickSeeCommunity (waitForUpdate) { if (this.props.canSave) { // save before transitioning to project page this.props.autoSave(); - requestSeeCommunity(true); // queue the transition to project page + waitForUpdate(true); // queue the transition to project page } else { - requestSeeCommunity(false); // immediately transition to project page + waitForUpdate(false); // immediately transition to project page } } - handleClickShare (requestSeeCommunity) { + handleClickShare (waitForUpdate) { if (!this.props.isShared) { if (this.props.canShare) { // save before transitioning to project page this.props.onShare(); } if (this.props.canSave) { // save before transitioning to project page this.props.autoSave(); - requestSeeCommunity(true); // queue the transition to project page + waitForUpdate(true); // queue the transition to project page } else { - requestSeeCommunity(false); // immediately transition to project page + waitForUpdate(false); // immediately transition to project page } } } @@ -480,17 +480,15 @@ class MenuBar extends React.Component { <div className={classNames(styles.menuBarItem)}> {this.props.canShare ? ( (this.props.isShowingProject || this.props.isUpdating) && ( - <ProjectWatcher - onShowingWithId={this.props.onSeeCommunity} - > + <ProjectWatcher onDoneUpdating={this.props.onSeeCommunity}> { - setRequesting => ( + waitForUpdate => ( <ShareButton className={styles.menuBarButton} isShared={this.props.isShared} /* eslint-disable react/jsx-no-bind */ onClick={() => { - this.handleClickShare(setRequesting); + this.handleClickShare(waitForUpdate); }} /* eslint-enable react/jsx-no-bind */ /> @@ -510,16 +508,14 @@ class MenuBar extends React.Component { <div className={classNames(styles.menuBarItem, styles.communityButtonWrapper)}> {this.props.enableCommunity ? ( (this.props.isShowingProject || this.props.isUpdating) && ( - <ProjectWatcher - onShowingWithId={this.props.onSeeCommunity} - > + <ProjectWatcher onDoneUpdating={this.props.onSeeCommunity}> { - setRequesting => ( + waitForUpdate => ( <CommunityButton className={styles.menuBarButton} /* eslint-disable react/jsx-no-bind */ onClick={() => { - this.handleClickSeeCommunity(setRequesting); + this.handleClickSeeCommunity(waitForUpdate); }} /* eslint-enable react/jsx-no-bind */ /> diff --git a/src/containers/project-watcher.jsx b/src/containers/project-watcher.jsx index dbcddd1cf21163e99b9f64717312d7fa0ef8e73b..706ef560a81261f4a152eb6c69a694500be57945 100644 --- a/src/containers/project-watcher.jsx +++ b/src/containers/project-watcher.jsx @@ -11,28 +11,28 @@ class ProjectWatcher extends React.Component { constructor (props) { super(props); bindAll(this, [ - 'setRequesting' + 'waitForSaving' ]); this.state = { - requesting: false + waiting: false }; } componentDidUpdate (prevProps) { - if (this.state.requesting && this.props.isShowingWithId && !prevProps.isShowingWithId) { + if (this.state.waiting && this.props.isShowingWithId && !prevProps.isShowingWithId) { this.fulfillRequest(); } } fulfillRequest () { - this.props.onShowingWithId(); + this.props.onDoneUpdating(); this.setState({ // eslint-disable-line react/no-did-update-set-state - requesting: false + waiting: false }); } - setRequesting (waitForRequest) { - if (waitForRequest) { + waitForSaving (isSaving) { + if (isSaving) { this.setState({ - requesting: true + waiting: true }); } else { // fulfill immediately this.fulfillRequest(); @@ -40,7 +40,7 @@ class ProjectWatcher extends React.Component { } render () { return this.props.children( - this.setRequesting + this.waitForSaving ); } } @@ -48,11 +48,11 @@ class ProjectWatcher extends React.Component { ProjectWatcher.propTypes = { children: PropTypes.func, isShowingWithId: PropTypes.bool, - onShowingWithId: PropTypes.func + onDoneUpdating: PropTypes.func }; ProjectWatcher.defaultProps = { - onShowingWithId: () => {} + onDoneUpdating: () => {} }; const mapStateToProps = state => {