提交 0de6f160 编写于 作者: J Jason Park

Warn before discarding changes

上级 0be0e02d
......@@ -50,11 +50,15 @@ class App extends React.Component {
CategoryApi.getCategories()
.then(({ categories }) => this.props.setCategories(categories))
.catch(this.props.showErrorToast);
window.onbeforeunload = () => this.isGistSaved() ? undefined : 'Changes you made will not be saved.';
}
componentWillUnmount() {
delete window.signIn;
delete window.signOut;
window.onbeforeunload = undefined;
}
componentWillReceiveProps(nextProps) {
......@@ -119,8 +123,9 @@ class App extends React.Component {
.catch(this.props.showErrorToast);
}
// TODO: warn before loading or quiting if not saved
loadAlgorithm({ categoryKey, algorithmKey, gistId }) {
if (!this.isGistSaved() && !window.confirm('Are you sure want to discard changes?')) return;
const { ext } = this.props.env;
let fetchPromise = null;
if (categoryKey && algorithmKey) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册