@qafka/react-native 2.3.6 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useVoiceChat.js +15 -6
- package/package.json +1 -1
|
@@ -358,12 +358,21 @@ function useVoiceChat({ apiUrl, apiKey, userContext, contextDescription, onToolS
|
|
|
358
358
|
}
|
|
359
359
|
}, []);
|
|
360
360
|
const connect = (0, react_1.useCallback)(async () => {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
361
|
+
// A service already exists for this voice session — do NOT create a second.
|
|
362
|
+
// The scroll handler fires connect() repeatedly while the pager settles on
|
|
363
|
+
// the voice page; the previous `isConnected` guard passed for two near-
|
|
364
|
+
// simultaneous calls (the first WS hadn't opened yet), so each spawned a
|
|
365
|
+
// RealtimeService and the first was orphaned but kept streaming mic + audio
|
|
366
|
+
// (two interleaved audio streams = choppy playback; the orphan still heard
|
|
367
|
+
// the mic = "mute didn't work"). Guard on existence, set synchronously
|
|
368
|
+
// below before any await, to close that race.
|
|
369
|
+
if (serviceRef.current) {
|
|
370
|
+
if (serviceRef.current.isConnected) {
|
|
371
|
+
// Re-entering the voice page after a swipe to chat (which calls pauseMic
|
|
372
|
+
// and stops native capture). The socket is still open — resume capture
|
|
373
|
+
// so the user can be heard again.
|
|
374
|
+
await serviceRef.current.resumeMic();
|
|
375
|
+
}
|
|
367
376
|
return;
|
|
368
377
|
}
|
|
369
378
|
setState('connecting');
|
package/package.json
CHANGED