Clean up SharePage beforeunload listener

This commit is contained in:
G.Ambatte
2026-10-11 13:32:07 +13:00
parent d7f579b308
commit 1efefce08d
@@ -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();
};
}, []);