fix: TDZ crash in useSpeechAudioCapture - move statusRef+_setStatusTracked before stop
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
2031c87529
commit
beeed79aaa
1 changed files with 6 additions and 6 deletions
|
|
@ -92,6 +92,12 @@ export function useVoiceStream(callbacks: VoiceStreamCallbacks): VoiceStreamApi
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const statusRef = useRef<VoiceStreamStatus>('idle');
|
||||||
|
const _setStatusTracked = useCallback((next: VoiceStreamStatus) => {
|
||||||
|
statusRef.current = next;
|
||||||
|
_setStatus(next);
|
||||||
|
}, [_setStatus]);
|
||||||
|
|
||||||
const stop = useCallback(() => {
|
const stop = useCallback(() => {
|
||||||
stoppingRef.current = true;
|
stoppingRef.current = true;
|
||||||
_stopRecorder();
|
_stopRecorder();
|
||||||
|
|
@ -113,12 +119,6 @@ export function useVoiceStream(callbacks: VoiceStreamCallbacks): VoiceStreamApi
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const statusRef = useRef<VoiceStreamStatus>('idle');
|
|
||||||
const _setStatusTracked = useCallback((next: VoiceStreamStatus) => {
|
|
||||||
statusRef.current = next;
|
|
||||||
_setStatus(next);
|
|
||||||
}, [_setStatus]);
|
|
||||||
|
|
||||||
const start = useCallback(async (language?: string, sttOpenOptions?: SttStreamOpenOptions) => {
|
const start = useCallback(async (language?: string, sttOpenOptions?: SttStreamOpenOptions) => {
|
||||||
if (statusRef.current === 'listening' || statusRef.current === 'connecting') return;
|
if (statusRef.current === 'listening' || statusRef.current === 'connecting') return;
|
||||||
stoppingRef.current = false;
|
stoppingRef.current = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue