client: better unload callback

This commit is contained in:
bordun 2020-03-30 18:26:18 +02:00
parent b625e3cb78
commit 1615369f83
2 changed files with 5 additions and 4 deletions

View file

@ -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

View file

@ -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')
}