diff --git a/web/src/hooks/useSignaling.ts b/web/src/hooks/useSignaling.ts index 388683b..b84534a 100644 --- a/web/src/hooks/useSignaling.ts +++ b/web/src/hooks/useSignaling.ts @@ -247,9 +247,9 @@ export function useSignaling(joinCode?: string) { break; case "pair-code-resolved": { // Store the groupId and reconnect to join the group room - const profileStore = useProfileStore.getState(); - profileStore.setGroupId(msg.groupId); - // Reconnect so the hello message includes the new groupId + useProfileStore.getState().setGroupId(msg.groupId); + // Update the signaling client's profile so reconnect sends the new groupId + signalingRef.current?.updateProfile({ groupId: msg.groupId }); signalingRef.current?.disconnect(); setTimeout(() => signalingRef.current?.connect(), 500); break; diff --git a/web/src/lib/signaling.ts b/web/src/lib/signaling.ts index 79af95c..6c1249a 100644 --- a/web/src/lib/signaling.ts +++ b/web/src/lib/signaling.ts @@ -64,6 +64,10 @@ export class SignalingClient { }; } + updateProfile(updates: Partial): void { + this.profile = { ...this.profile, ...updates }; + } + send(msg: ClientMessage): void { if (this.ws?.readyState === WebSocket.OPEN) { this.ws.send(JSON.stringify(msg));