Skip to content

Commit 8485048

Browse files
authored
skip calling onError for audio player errors if call is disconnected (#348)
1 parent 7af1c64 commit 8485048

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

packages/embed-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@humeai/voice-embed-react",
3-
"version": "0.2.0-beta.18",
3+
"version": "0.2.0-beta.19",
44
"description": "",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/embed/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@humeai/voice-embed",
3-
"version": "0.2.0-beta.18",
3+
"version": "0.2.0-beta.19",
44
"description": "",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@humeai/voice-react",
3-
"version": "0.2.0-beta.18",
3+
"version": "0.2.0-beta.19",
44
"description": "",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

packages/react/src/lib/VoiceProvider.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ export const VoiceProvider: FC<VoiceProviderProps> = ({
285285
const player = useSoundPlayer({
286286
enableAudioWorklet,
287287
onError: (message, reason) => {
288+
if (checkIsDisconnecting() || checkIsDisconnected()) {
289+
return;
290+
}
288291
updateError({ type: 'audio_error', reason, message });
289292
},
290293
onPlayAudio: (id: string) => {
@@ -511,13 +514,6 @@ export const VoiceProvider: FC<VoiceProviderProps> = ({
511514
return;
512515
}
513516

514-
if (checkIsDisconnecting()) {
515-
console.warn(
516-
'Currently disconnecting from a chat. Cannot connect until the previous call is disconnected.',
517-
);
518-
return;
519-
}
520-
521517
updateError(null);
522518
setStatus({ value: 'connecting' });
523519
resourceStatusRef.current.socket = 'connecting';
@@ -618,7 +614,6 @@ export const VoiceProvider: FC<VoiceProviderProps> = ({
618614
isConnectingRef.current = false;
619615
},
620616
[
621-
checkIsDisconnecting,
622617
checkShouldContinueConnecting,
623618
client,
624619
config,

0 commit comments

Comments
 (0)