diff --git a/src/components/menu-bar/menu-bar.jsx b/src/components/menu-bar/menu-bar.jsx index 12fe0c2737035f3fb23ad313cae67370bd25c143..35939d37769f17787a64b16b4150b1d37d60d31f 100644 --- a/src/components/menu-bar/menu-bar.jsx +++ b/src/components/menu-bar/menu-bar.jsx @@ -27,6 +27,7 @@ import TurboMode from '../../containers/turbo-mode.jsx'; import {openTipsLibrary} from '../../reducers/modals'; import {setPlayer} from '../../reducers/mode'; import { + autoUpdateProject, getIsUpdating, getIsShowingProject, manualUpdateProject, @@ -172,17 +173,23 @@ class MenuBar extends React.Component { } handleClickSeeCommunity (requestSeeCommunity) { if (this.props.canSave) { // save before transitioning to project page - this.props.onClickSave(); + this.props.autoSave(); + requestSeeCommunity(true); // queue the transition to project page + } else { + requestSeeCommunity(false); // immediately transition to project page } - requestSeeCommunity(); // queue the transition to project page } handleClickShare (requestSeeCommunity) { - if (this.props.canSave && !this.props.isShared) { // save before transitioning to project page - this.props.onClickSave(); - } - if (this.props.canShare && !this.props.isShared) { // save before transitioning to project page - this.props.onShare(); - requestSeeCommunity(); // queue the transition to project page + 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 + } else { + requestSeeCommunity(false); // immediately transition to project page + } } } handleRestoreOption (restoreFun) { @@ -681,6 +688,7 @@ MenuBar.propTypes = { authorId: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), authorThumbnailUrl: PropTypes.string, authorUsername: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), + autoUpdateProject: PropTypes.func, canCreateCopy: PropTypes.bool, canCreateNew: PropTypes.bool, canEditTitle: PropTypes.bool, @@ -749,6 +757,7 @@ const mapStateToProps = state => { }; const mapDispatchToProps = dispatch => ({ + autoSave: () => dispatch(autoUpdateProject()), onOpenTipLibrary: () => dispatch(openTipsLibrary()), onClickAccount: () => dispatch(openAccountMenu()), onRequestCloseAccount: () => dispatch(closeAccountMenu()), diff --git a/src/containers/project-watcher.jsx b/src/containers/project-watcher.jsx index 8a75f8e2b684bd705f4c81b7a8040cf01966ba6f..dbcddd1cf21163e99b9f64717312d7fa0ef8e73b 100644 --- a/src/containers/project-watcher.jsx +++ b/src/containers/project-watcher.jsx @@ -20,18 +20,24 @@ class ProjectWatcher extends React.Component { } componentDidUpdate (prevProps) { if (this.state.requesting && this.props.isShowingWithId && !prevProps.isShowingWithId) { - this.props.onShowingWithId(); - this.setState({ // eslint-disable-line react/no-did-update-set-state - requesting: false - }); + this.fulfillRequest(); } - } - setRequesting () { - this.setState({ - requesting: true + fulfillRequest () { + this.props.onShowingWithId(); + this.setState({ // eslint-disable-line react/no-did-update-set-state + requesting: false }); } + setRequesting (waitForRequest) { + if (waitForRequest) { + this.setState({ + requesting: true + }); + } else { // fulfill immediately + this.fulfillRequest(); + } + } render () { return this.props.children( this.setRequesting