ipc: emit 'close' when closing/refreshing tab

This commit is contained in:
bordun 2020-03-30 18:00:16 +02:00
parent 200394ec6c
commit 0f8b11cbfd
3 changed files with 8 additions and 6 deletions

View file

@ -102,10 +102,6 @@ class Editor {
this.grid = true
this.unsavedSession = false
window.onbeforeunload = ()=>{
if (this.unsavedSession) return true
}
this.history = []
this.historyState = -1

View file

@ -19,15 +19,21 @@ document.addEventListener('DOMContentLoaded', function(event) {
var ipc = require('./ipc/'),
backup = require('./backup')
ipc.init()
require('./ui/init')
var editor = require('./editor')
document.title = TITLE
ipc.send('open', {hotReload: backup.exists})
window.onbeforeunload = ()=>{
if (editor.unsavedSession) return true
ipc.send('close')
}
backup.load()

View file

@ -95,7 +95,7 @@ module.exports = {
reload: function(){
backup.save()
window.onbeforeunload = null
editor.unsavedSession = false
window.location.href = window.location.href
},