v0.7.1 minor bug fixes

This commit is contained in:
2026-03-11 14:37:49 -04:00
parent fd041ea95a
commit a1f0c35e8d
10 changed files with 43 additions and 15 deletions

View File

@@ -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]);