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