fix(quit): On Win32, Linux, N1 should not quit when the main window is closed

Fixes #475
This commit is contained in:
Ben Gotow 2015-12-01 14:08:26 -08:00
parent bd9181f62e
commit 439529c51f

View file

@ -485,16 +485,21 @@ class WindowManager
window.removeListener('window:close-prevented', closePreventedHandler) window.removeListener('window:close-prevented', closePreventedHandler)
windowClosedOrHidden: -> windowClosedOrHidden: ->
# On Windows and Linux, we want to terminate the app after the last visible # Typically, N1 stays running in the background on all platforms, since it
# window is closed. However, there are brief moments where the app has no # has a status icon you can use to quit it.
# windows, like when you log out or finish logging in. Wait a while after #
# the last window close event to see if we should quit. # However, on Windows and Linux we /do/ want to quit if the app is somehow
# put into a state where there are no visible windows and the main window
# doesn't exist.
#
# This /shouldn't/ happen, but if it does, the only way for them to recover
# would be to pull up the Task Manager. Ew.
#
if process.platform in ['win32', 'linux'] if process.platform in ['win32', 'linux']
@quitCheck ?= _.debounce => @quitCheck ?= _.debounce =>
noVisibleWindows = @visibleWindows().length is 0 noVisibleWindows = @visibleWindows().length is 0
mainWindowLoading = @mainWindow() and not @mainWindow().isLoaded() noMainWindowLoaded = not @mainWindow()?.isLoaded()
workWindowLoading = @workWindow() and not @workWindow().isLoaded() if noVisibleWindows and noMainWindowLoaded
if noVisibleWindows and not mainWindowLoading and not workWindowLoading
app.quit() app.quit()
, 10000 , 10000
@quitCheck() @quitCheck()