mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-05 08:57:43 +00:00
fix: ensure username and tab title are sent and stored on initial join
This commit is contained in:
+11
-7
@@ -206,6 +206,7 @@ async function connect() {
|
||||
password: settings.password,
|
||||
peerId,
|
||||
username: settings.username,
|
||||
tabTitle: currentTabTitle,
|
||||
protocolVersion: PROTOCOL_VERSION
|
||||
});
|
||||
}
|
||||
@@ -561,14 +562,17 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
}, () => {
|
||||
if (socket && socket.readyState === WebSocket.OPEN && isNamespaceJoined) {
|
||||
// FORCE TRANSITION: Emit Join Room directly if already connected
|
||||
emit(EVENTS.JOIN_ROOM, {
|
||||
roomId,
|
||||
password,
|
||||
peerId,
|
||||
username: message.username || '', // Use username if provided by bridge
|
||||
protocolVersion: PROTOCOL_VERSION
|
||||
getSettings().then(settings => {
|
||||
emit(EVENTS.JOIN_ROOM, {
|
||||
roomId,
|
||||
password,
|
||||
peerId,
|
||||
username: settings.username, // Use local settings, not bridge
|
||||
tabTitle: currentTabTitle,
|
||||
protocolVersion: PROTOCOL_VERSION
|
||||
});
|
||||
addLog(`Joining room via link: ${roomId}`, 'info');
|
||||
});
|
||||
addLog(`Joining room via link: ${roomId}`, 'info');
|
||||
} else {
|
||||
connect();
|
||||
}
|
||||
|
||||
+3
-3
@@ -154,7 +154,7 @@ io.on('connection', (socket) => {
|
||||
return;
|
||||
}
|
||||
if (!payload || typeof payload.roomId !== 'string') return;
|
||||
const { roomId, password, peerId, username, protocolVersion } = payload;
|
||||
const { roomId, password, peerId, username, tabTitle, protocolVersion } = payload;
|
||||
try {
|
||||
// Protocol check
|
||||
if (protocolVersion !== '1.0.0') {
|
||||
@@ -242,12 +242,12 @@ io.on('connection', (socket) => {
|
||||
room.peerData.set(socket.id, {
|
||||
peerId,
|
||||
username: username || null,
|
||||
tabTitle: null,
|
||||
tabTitle: tabTitle || null,
|
||||
lastSeen: Date.now()
|
||||
});
|
||||
socketToRoom.set(socket.id, { roomId, peerId });
|
||||
|
||||
socket.to(roomId).emit(EVENTS.PEER_STATUS, { peerId, username: username || null, status: 'joined' });
|
||||
socket.to(roomId).emit(EVENTS.PEER_STATUS, { peerId, username: username || null, tabTitle: tabTitle || null, status: 'joined' });
|
||||
socket.emit(EVENTS.ROOM_DATA, {
|
||||
roomId,
|
||||
peers: Array.from(room.peers).map(sid => room.peerData.get(sid))
|
||||
|
||||
Reference in New Issue
Block a user