use browser 'online' event to trigger reconnect

This commit is contained in:
Brian Gough 2016-11-03 12:27:19 +00:00
parent 87d8192d29
commit 2a8efea29a

View file

@ -20,6 +20,12 @@ define [], () ->
@disconnectIfInactive() @disconnectIfInactive()
, ONEHOUR) , ONEHOUR)
# trigger a reconnect immediately if network comes back online
window.addEventListener 'online', =>
sl_console.log "[online] browser notified online"
if !@connected
@tryReconnectWithRateLimit({force:true})
@userIsLeavingPage = false @userIsLeavingPage = false
window.addEventListener 'beforeunload', => window.addEventListener 'beforeunload', =>
@userIsLeavingPage = true @userIsLeavingPage = true