* 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">
|
<p className="nav__open">
|
||||||
<Link
|
<Link
|
||||||
to={`/${this.props.user.username}/sketches`}
|
to={`/${this.props.user.username}/sketches`}
|
||||||
onClick={this.props.stopSketch}
|
|
||||||
>
|
>
|
||||||
Open
|
Open
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -94,7 +93,9 @@ class Nav extends React.PureComponent {
|
||||||
})()}
|
})()}
|
||||||
<li className="nav__item">
|
<li className="nav__item">
|
||||||
<p className="nav__open">
|
<p className="nav__open">
|
||||||
<Link to="/p5/sketches">
|
<Link
|
||||||
|
to="/p5/sketches"
|
||||||
|
>
|
||||||
Examples
|
Examples
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
|
@ -187,7 +188,6 @@ Nav.propTypes = {
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
logoutUser: PropTypes.func.isRequired,
|
logoutUser: PropTypes.func.isRequired,
|
||||||
stopSketch: PropTypes.func.isRequired,
|
|
||||||
showShareModal: PropTypes.func.isRequired,
|
showShareModal: PropTypes.func.isRequired,
|
||||||
showErrorModal: PropTypes.func.isRequired,
|
showErrorModal: PropTypes.func.isRequired,
|
||||||
unsavedChanges: PropTypes.bool.isRequired,
|
unsavedChanges: PropTypes.bool.isRequired,
|
||||||
|
|
|
@ -11,11 +11,16 @@ import NewPasswordView from './modules/User/pages/NewPasswordView';
|
||||||
import AccountView from './modules/User/pages/AccountView';
|
import AccountView from './modules/User/pages/AccountView';
|
||||||
// import SketchListView from './modules/Sketch/pages/SketchListView';
|
// import SketchListView from './modules/Sketch/pages/SketchListView';
|
||||||
import { getUser } from './modules/User/actions';
|
import { getUser } from './modules/User/actions';
|
||||||
|
import { stopSketch } from './modules/IDE/actions/ide';
|
||||||
|
|
||||||
const checkAuth = (store) => {
|
const checkAuth = (store) => {
|
||||||
store.dispatch(getUser());
|
store.dispatch(getUser());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onRouteChange = (store) => {
|
||||||
|
store.dispatch(stopSketch());
|
||||||
|
};
|
||||||
|
|
||||||
const routes = (store) => {
|
const routes = (store) => {
|
||||||
const sourceProtocol = findSourceProtocol(store.getState());
|
const sourceProtocol = findSourceProtocol(store.getState());
|
||||||
|
|
||||||
|
@ -28,7 +33,7 @@ const routes = (store) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Route path="/" component={App}>
|
<Route path="/" component={App} onChange={() => { onRouteChange(store); }}>
|
||||||
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
|
<IndexRoute component={IDEView} onEnter={checkAuth(store)} />
|
||||||
<Route path="/login" component={forceToHttps(LoginView)} />
|
<Route path="/login" component={forceToHttps(LoginView)} />
|
||||||
<Route path="/signup" component={forceToHttps(SignupView)} />
|
<Route path="/signup" component={forceToHttps(SignupView)} />
|
||||||
|
|
Loading…
Reference in a new issue