v0.7.1 minor bug fixes
This commit is contained in:
@@ -194,9 +194,21 @@ export default function Chat() {
|
||||
});
|
||||
};
|
||||
|
||||
// Session displaced: another login on the same device type kicked us out
|
||||
const handleSessionDisplaced = ({ device: displacedDevice }) => {
|
||||
// Only act if it's our device slot that was taken over
|
||||
// (The server emits to user room so all sockets of this user receive it;
|
||||
// our socket's device is embedded in the socket but we can't read it here,
|
||||
// so we force logout unconditionally — the new session will reconnect cleanly)
|
||||
localStorage.removeItem('tc_token');
|
||||
sessionStorage.removeItem('tc_token');
|
||||
window.dispatchEvent(new CustomEvent('jama:session-displaced'));
|
||||
};
|
||||
|
||||
socket.on('group:new', handleGroupNew);
|
||||
socket.on('group:deleted', handleGroupDeleted);
|
||||
socket.on('group:updated', handleGroupUpdated);
|
||||
socket.on('session:displaced', handleSessionDisplaced);
|
||||
|
||||
// Bug B fix: on reconnect, reload groups to catch any messages missed while offline
|
||||
const handleReconnect = () => { loadGroups(); };
|
||||
@@ -217,6 +229,7 @@ export default function Chat() {
|
||||
socket.off('group:deleted', handleGroupDeleted);
|
||||
socket.off('group:updated', handleGroupUpdated);
|
||||
socket.off('connect', handleReconnect);
|
||||
socket.off('session:displaced', handleSessionDisplaced);
|
||||
document.removeEventListener('visibilitychange', handleVisibility);
|
||||
};
|
||||
}, [socket, toast, activeGroupId, user, isMobile, loadGroups]);
|
||||
|
||||
Reference in New Issue
Block a user