File tree 1 file changed +6
-1
lines changed
src/frontend/components/App
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -50,11 +50,15 @@ class App extends React.Component {
50
50
CategoryApi . getCategories ( )
51
51
. then ( ( { categories } ) => this . props . setCategories ( categories ) )
52
52
. catch ( this . props . showErrorToast ) ;
53
+
54
+ window . onbeforeunload = ( ) => this . isGistSaved ( ) ? undefined : 'Changes you made will not be saved.' ;
53
55
}
54
56
55
57
componentWillUnmount ( ) {
56
58
delete window . signIn ;
57
59
delete window . signOut ;
60
+
61
+ window . onbeforeunload = undefined ;
58
62
}
59
63
60
64
componentWillReceiveProps ( nextProps ) {
@@ -119,8 +123,9 @@ class App extends React.Component {
119
123
. catch ( this . props . showErrorToast ) ;
120
124
}
121
125
122
- // TODO: warn before loading or quiting if not saved
123
126
loadAlgorithm ( { categoryKey, algorithmKey, gistId } ) {
127
+ if ( ! this . isGistSaved ( ) && ! window . confirm ( 'Are you sure want to discard changes?' ) ) return ;
128
+
124
129
const { ext } = this . props . env ;
125
130
let fetchPromise = null ;
126
131
if ( categoryKey && algorithmKey ) {
You can’t perform that action at this time.
0 commit comments