Set status to offline when closing app

This commit is contained in:
Alexander Zinchuk 2021-06-21 04:25:55 +03:00
parent 4befdbd741
commit 34b73a70a7

View File

@ -137,6 +137,18 @@ const Main: FC<StateProps & DispatchProps> = ({
updateIsOnline(true);
});
useEffect(() => {
function handleUnload() {
updateIsOnline(false);
}
window.addEventListener('beforeunload', handleUnload);
return () => {
window.removeEventListener('beforeunload', handleUnload);
};
}, [updateIsOnline]);
// Browser tab indicators
useBackgroundMode(() => {
const initialUnread = selectCountNotMutedUnread(getGlobal());