Skip to content

Commit

Permalink
2916: fix tests and minor issues, reset index on close
Browse files Browse the repository at this point in the history
  • Loading branch information
f1sh1918 committed Jan 24, 2025
1 parent f039383 commit f66b907
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions native/src/components/TtsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const TtsContainer = ({ children }: TtsContainerProps): ReactElement => {

const stop = useCallback(async (resetIndex = false) => {
suppressFinishEventOnIos()
Tts.stop().then(() => setIsPlaying(false))
Tts.stop()
setIsPlaying(false)
if (resetIndex) {
setSentenceIndex(0)
await new Promise(resolve => {
Expand Down Expand Up @@ -137,7 +138,9 @@ const TtsContainer = ({ children }: TtsContainerProps): ReactElement => {
if (!enabled) {
return () => undefined
}
return () => initializeTts()

initializeTts()
return () => undefined
}, [enabled, initializeTts])

useEffect(() => {
Expand All @@ -162,13 +165,13 @@ const TtsContainer = ({ children }: TtsContainerProps): ReactElement => {

const close = async () => {
setVisible(false)
stop()
stop(true)
}

const updateSentences = useCallback(
(newSentences: string[]) => {
setSentences(newSentences)
stop().then()
stop(true).then()
},
[stop],
)
Expand Down
2 changes: 1 addition & 1 deletion native/src/components/__tests__/TtsContainer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('TtsContainer', () => {
expect.objectContaining({
androidParams: expect.any(Object),
iosVoiceId: '',
rate: 1,
rate: 0.45,
}),
)
})
Expand Down

0 comments on commit f66b907

Please sign in to comment.