Closed tfnribeiro closed 6 months ago
I found the cause for this bug.
We initialize a SpeechContext which is only done within the Exercises. The articles initialize the ZeeguuSpeech whenever an interactive text is created. This leads the Words that are initialized without the context to break, since there is no Context passed.
I have a working fix that initializes the SpeechContext at Log In, then this is passed down to any components later on. I am still trying to figure out if I can include it in the InteractiveReader as well. This would make it so that we only initialize it once per Session for a user (hopefully!)
Argh!
That's one way. Another way is to initialize it on the creation of the Top Words components.
The thing is you'd have to put it in a context if you initialize it only once. Because it has to change when one changes the language in settings for example. See what I mean?
I see, yeah I haven't considered that!
Well, I would propose then that we create a wrapper around the setUser. If we update it whenever the user changes it then it can be updated through useRef.
It seems to work. I have tried going from da to fr and back to da successfully.
However, in French it doesn't play the animation. Is that expected?
You'll have to explain to me how do you solve this with the useRef!
It should play the animation always. The only difference between fr and da is that in da we're playing an mp3, and in fr we're using text to speech I think. So in some sense, it should be so fast that there should be no need for animation maybe?
A use context is now used at the LoggedInRouter level and passed down to the components that need it.
When I click the sound button in the Word tab the sound doesn't play (for Danish).