* 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:
parent
1ae37ebaaa
commit
7403b2b2d6
2 changed files with 9 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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)} />
|
||||
|
|
Loading…
Reference in a new issue