Clean up SharePage beforeunload listener
This commit is contained in:
1 parent
d7f579b308
commit
1efefce08d
1 file changed
+4
-2
@@ -78,12 +78,14 @@ const SharePage = (props)=>{
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', async ()=>{
|
||||
async function unsub(){
|
||||
await request.get(`/api/stream/unsubscribe/${subId}`);
|
||||
});
|
||||
};
|
||||
window.addEventListener('beforeunload', unsub);
|
||||
|
||||
return async ()=>{
|
||||
document.removeEventListener('keydown', handleControlKeys);
|
||||
window.addEventListener('beforeunload', unsub);
|
||||
eventSource.close();
|
||||
};
|
||||
}, []);
|
||||
|
||||
Reference in new issue
Block a user