client: better unload callback
This commit is contained in:
parent
b625e3cb78
commit
1615369f83
2 changed files with 5 additions and 4 deletions
|
|
@ -102,7 +102,10 @@ class Editor {
|
|||
this.grid = true
|
||||
|
||||
this.unsavedSession = false
|
||||
|
||||
window.onbeforeunload = ()=>{
|
||||
if (editor.unsavedSession) return true
|
||||
}
|
||||
|
||||
this.history = []
|
||||
this.historyState = -1
|
||||
this.historySession = null
|
||||
|
|
|
|||
|
|
@ -22,14 +22,12 @@ document.addEventListener('DOMContentLoaded', function(event) {
|
|||
|
||||
|
||||
require('./ui/init')
|
||||
var editor = require('./editor')
|
||||
|
||||
document.title = TITLE
|
||||
|
||||
ipc.send('open', {hotReload: backup.exists})
|
||||
|
||||
window.onbeforeunload = ()=>{
|
||||
if (editor.unsavedSession) return true
|
||||
window.onunload = ()=>{
|
||||
ipc.send('close')
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue