fix: pairing reconnect sends stale groupId
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 37s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 37s
SignalingClient captured the profile at construction time, so after pair-code-resolved updated the store, the reconnect still sent the old groupId. Added updateProfile() method and call it before reconnecting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d8721b6d0c
commit
b407e6ce95
@ -247,9 +247,9 @@ export function useSignaling(joinCode?: string) {
|
|||||||
break;
|
break;
|
||||||
case "pair-code-resolved": {
|
case "pair-code-resolved": {
|
||||||
// Store the groupId and reconnect to join the group room
|
// Store the groupId and reconnect to join the group room
|
||||||
const profileStore = useProfileStore.getState();
|
useProfileStore.getState().setGroupId(msg.groupId);
|
||||||
profileStore.setGroupId(msg.groupId);
|
// Update the signaling client's profile so reconnect sends the new groupId
|
||||||
// Reconnect so the hello message includes the new groupId
|
signalingRef.current?.updateProfile({ groupId: msg.groupId });
|
||||||
signalingRef.current?.disconnect();
|
signalingRef.current?.disconnect();
|
||||||
setTimeout(() => signalingRef.current?.connect(), 500);
|
setTimeout(() => signalingRef.current?.connect(), 500);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -64,6 +64,10 @@ export class SignalingClient {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateProfile(updates: Partial<ProfileData>): void {
|
||||||
|
this.profile = { ...this.profile, ...updates };
|
||||||
|
}
|
||||||
|
|
||||||
send(msg: ClientMessage): void {
|
send(msg: ClientMessage): void {
|
||||||
if (this.ws?.readyState === WebSocket.OPEN) {
|
if (this.ws?.readyState === WebSocket.OPEN) {
|
||||||
this.ws.send(JSON.stringify(msg));
|
this.ws.send(JSON.stringify(msg));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user