File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -416,11 +416,8 @@ export function TTSProvider({ children }: { children: React.ReactNode }) {
416416 const stopAndPlayFromIndex = useCallback ( ( index : number ) => {
417417 abortAudio ( ) ;
418418
419- // Set the states in the next tick to ensure clean state
420- setTimeout ( ( ) => {
421- setCurrentIndex ( index ) ;
422- setIsPlaying ( true ) ;
423- } , 50 ) ;
419+ setCurrentIndex ( index ) ;
420+ setIsPlaying ( true ) ;
424421 } , [ abortAudio ] ) ;
425422
426423 const setCurrentIndexWithoutPlay = useCallback ( ( index : number ) => {
@@ -437,11 +434,8 @@ export function TTSProvider({ children }: { children: React.ReactNode }) {
437434 if ( isPlaying ) {
438435 const currentIdx = currentIndex ;
439436 stop ( ) ;
440- // Small delay to ensure audio is fully stopped
441- setTimeout ( ( ) => {
442- setCurrentIndex ( currentIdx ) ;
443- setIsPlaying ( true ) ;
444- } , 50 ) ;
437+ setCurrentIndex ( currentIdx ) ;
438+ setIsPlaying ( true ) ;
445439 }
446440 } , [ isPlaying , currentIndex , stop ] ) ;
447441
@@ -453,11 +447,8 @@ export function TTSProvider({ children }: { children: React.ReactNode }) {
453447 if ( isPlaying ) {
454448 const currentIdx = currentIndex ;
455449 stop ( ) ;
456- // Small delay to ensure audio is fully stopped
457- setTimeout ( ( ) => {
458- setCurrentIndex ( currentIdx ) ;
459- setIsPlaying ( true ) ;
460- } , 50 ) ;
450+ setCurrentIndex ( currentIdx ) ;
451+ setIsPlaying ( true ) ;
461452 }
462453 } , [ isPlaying , currentIndex , stop ] ) ;
463454
You can’t perform that action at this time.
0 commit comments