fix(window-state): Per electron#7278, save state in beforeunload

Related:
https://github.com/electron/electron/issues/7278
https://github.com/atom/atom/pull/3223/files

As of Chromium 36, unload is async and @zcbenz does not think it happens reliabily in Electron. Move saving of window state to beforeunload, following suit with Atom.
This commit is contained in:
Ben Gotow 2016-09-28 17:39:25 -07:00
parent f62caa9c57
commit 9ddb713a1b

View file

@ -39,14 +39,13 @@ class WindowEventHandler
# throttled in case more work needs to be done before closing
# In Electron, returning any value other than undefined cancels the close.
canCloseWindow = @runUnloadCallbacks()
return undefined if canCloseWindow
if @runUnloadCallbacks()
# Good to go! Window will be closing...
NylasEnv.storeWindowDimensions()
NylasEnv.saveStateAndUnloadWindow()
return undefined
return false
window.onunload = =>
NylasEnv.storeWindowDimensions()
NylasEnv.saveStateAndUnloadWindow()
NylasEnv.commands.add document.body, 'window:toggle-full-screen', ->
NylasEnv.toggleFullScreen()