File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
src/frontend/components/App Expand file tree Collapse file tree 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 {
5050 CategoryApi . getCategories ( )
5151 . then ( ( { categories } ) => this . props . setCategories ( categories ) )
5252 . catch ( this . props . showErrorToast ) ;
53+
54+ window . onbeforeunload = ( ) => this . isGistSaved ( ) ? undefined : 'Changes you made will not be saved.' ;
5355 }
5456
5557 componentWillUnmount ( ) {
5658 delete window . signIn ;
5759 delete window . signOut ;
60+
61+ window . onbeforeunload = undefined ;
5862 }
5963
6064 componentWillReceiveProps ( nextProps ) {
@@ -119,8 +123,9 @@ class App extends React.Component {
119123 . catch ( this . props . showErrorToast ) ;
120124 }
121125
122- // TODO: warn before loading or quiting if not saved
123126 loadAlgorithm ( { categoryKey, algorithmKey, gistId } ) {
127+ if ( ! this . isGistSaved ( ) && ! window . confirm ( 'Are you sure want to discard changes?' ) ) return ;
128+
124129 const { ext } = this . props . env ;
125130 let fetchPromise = null ;
126131 if ( categoryKey && algorithmKey ) {
You can’t perform that action at this time.
0 commit comments