moved to before-unload event
This commit is contained in:
parent
93cc4c14ae
commit
a098da6f09
@ -1,5 +1,5 @@
|
||||
// Handle server connection
|
||||
document.body.onunload = () => {
|
||||
window.addEventListener('beforeunload', () => {
|
||||
if (user.connected)
|
||||
fetch('/disconnect', {
|
||||
method: 'POST',
|
||||
@ -11,7 +11,7 @@ document.body.onunload = () => {
|
||||
id: user.id
|
||||
})
|
||||
}).then(res => {});
|
||||
};
|
||||
});
|
||||
fetch('/connect').then(res => {
|
||||
if (res.status === 200) {
|
||||
user.connected = true;
|
||||
|
Loading…
Reference in New Issue
Block a user