Last active
January 9, 2018 20:47
-
-
Save PrimeTimeTran/6aa50585c09f9df7f7676b36e193299f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PURPOSE: | |
// to prevent green dot from going grey on simple user navigations to different parts of the app | |
// PROBLEM: | |
// if the user 'x's the tab of their browser, this ActionCable method never runs, thus the user is always online | |
disconnected: function() { | |
setTimeout(function () { | |
if (!App.cable) { | |
this.perform("disappear"); | |
} | |
}, 5000); | |
}, | |
// PURPOSE: | |
// to fire `this.perform('disappear') if the user closes the tab or navigates to a different domain | |
// PROBLEM: | |
// if the user navigates to a different page this is also fired... thus, defeats the purpose of `setTimeout()` on line 7 | |
window.onbeforeunload = function () { | |
this.perform("disappear"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment