Skip to content

Commit a1136be

Browse files
authored
Merge pull request #5 from richardr1126/single-page-viewer
Text to click fix
2 parents dc95ea8 + 2201dac commit a1136be

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/contexts/TTSContext.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)