Current sketch will stop playing if a new example is opened (issue #357) (#365)

* Current sketch will stop playing if a new example is opened (#357)

* stopSketch dispatches on route change

* Remove extra stopSketcch calls
This commit is contained in:
Zach Rispoli 2017-06-18 17:11:23 -04:00 committed by Cassie Tarakajian
parent 1ae37ebaaa
commit 7403b2b2d6
2 changed files with 9 additions and 4 deletions

View File

@ -83,7 +83,6 @@ class Nav extends React.PureComponent {
<p className="nav__open">
<Link
to={`/${this.props.user.username}/sketches`}
onClick={this.props.stopSketch}
>
Open
</Link>
@ -94,7 +93,9 @@ class Nav extends React.PureComponent {
})()}
<li className="nav__item">
<p className="nav__open">
<Link to="/p5/sketches">
<Link
to="/p5/sketches"
>
Examples
</Link>
</p>
@ -187,7 +188,6 @@ Nav.propTypes = {
})
}),
logoutUser: PropTypes.func.isRequired,
stopSketch: PropTypes.func.isRequired,
showShareModal: PropTypes.func.isRequired,
showErrorModal: PropTypes.func.isRequired,
unsavedChanges: PropTypes.bool.isRequired,

View File

@ -11,11 +11,16 @@ import NewPasswordView from './modules/User/pages/NewPasswordView';
import AccountView from './modules/User/pages/AccountView';
// import SketchListView from './modules/Sketch/pages/SketchListView';
import { getUser } from './modules/User/actions';
import { stopSketch } from './modules/IDE/actions/ide';
const checkAuth = (store) => {
store.dispatch(getUser());
};
const onRouteChange = (store) => {
store.dispatch(stopSketch());
};
const routes = (store) => {
const sourceProtocol = findSourceProtocol(store.getState());
@ -28,7 +33,7 @@ const routes = (store) => {
});
return (
<Route path="/" component={App}>
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
<Route path="/login" component={forceToHttps(LoginView)} />
<Route path="/signup" component={forceToHttps(SignupView)} />