-
Notifications
You must be signed in to change notification settings - Fork 362
Fix audio player bar not loaded when changing chapter #854
Conversation
- Fix currentVerse undefined - Restart currentTime to 0 when chapter changed
rebuild |
1 similar comment
rebuild |
@imadmk Jenkins will soon generate an environment for this pr, so we can test and I'll approve the pr. thank you |
Deployed to: http://staging.quran.com:32933 |
Deployed to: http://staging.quran.com:32934 |
@@ -447,7 +447,7 @@ class Surah extends Component { | |||
<Audioplayer | |||
chapter={chapter} | |||
verses={verses} | |||
currentVerse={verses[currentVerse]} | |||
currentVerse={verses[currentVerse] || verses[Object.keys(verses)[0]]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we're doing the same thing in mapStateToProps
, currentVerse shouldn't be nil.
Also this will fix the audio player what about other components which are using currentVerse
? see renderVerses
and renderLines
for example. I believe we should fix mapStateToProps
and make sure current verse isn't undefine at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imadmk like I said Fixed. And closing this. |
I see. Great it fixed. Because that will fix many UI flows. |
Assalamualaikum
Bismillah this is my first contribution.
Insha Allah this commit will fix issue 815 and 830 and maybe 675 too
Fix currentVerse undefined
I found when user change verse, the currentVerse is not changed. So if user already on 4th verse on Surah 1 and move to Surah 3 for example, it will cause Audioplayer breaks (on staging, and endless loading on production) because
ownProps.currentVerse
is undefined onfiles[ownProps.currentVerse.verseKey]
(on Audioplayer/index.js).This is caused by undefined
verses[currentVerse]' on 'Surah/index.js
upon rendering Audioplayer.When new surah loads,
verses
will be assigned bystate.verses.entities[chapterId]
so it will be filled with {3:1, 3:2, 3:3 ...}.So it will be undefined since
currentVerse
is still on1:4
and verses[1:4] does not exist.This fix will assign
currentVerse
to first element from verses when it is undefined.Restart currentTime to 0 when chapter changed
After audio player succesfully loaded, the state of
currentTime
did not change. So if the player already played to half of the ayah, it won't reset to0
in new Surah.This fix will reset the
currentTime
to 0 every unmounting Audioplayer element.