mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-11-04 22:38:43 +00:00
Clean up SharePage beforeunload listener
This commit is contained in:
@@ -78,12 +78,14 @@ const SharePage = (props)=>{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('beforeunload', async ()=>{
|
async function unsub(){
|
||||||
await request.get(`/api/stream/unsubscribe/${subId}`);
|
await request.get(`/api/stream/unsubscribe/${subId}`);
|
||||||
});
|
};
|
||||||
|
window.addEventListener('beforeunload', unsub);
|
||||||
|
|
||||||
return async ()=>{
|
return async ()=>{
|
||||||
document.removeEventListener('keydown', handleControlKeys);
|
document.removeEventListener('keydown', handleControlKeys);
|
||||||
|
window.addEventListener('beforeunload', unsub);
|
||||||
eventSource.close();
|
eventSource.close();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user