Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Fix audio player bar not loaded when changing chapter #854

Closed
wants to merge 3 commits into from

Conversation

imadmk
Copy link
Contributor

@imadmk imadmk commented Aug 13, 2017

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 on files[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 by state.verses.entities[chapterId] so it will be filled with {3:1, 3:2, 3:3 ...}.
    So it will be undefined since currentVerse is still on 1: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 to 0 in new Surah.
    This fix will reset the currentTime to 0 every unmounting Audioplayer element.

MK. Imaduddin added 2 commits August 8, 2017 23:10
- Fix currentVerse undefined
- Restart currentTime to 0 when chapter changed
@naveed-ahmad
Copy link
Contributor

rebuild

1 similar comment
@thabti
Copy link
Contributor

thabti commented Aug 23, 2017

rebuild

@thabti
Copy link
Contributor

thabti commented Aug 23, 2017

@imadmk Jenkins will soon generate an environment for this pr, so we can test and I'll approve the pr.

thank you

@ahmedre
Copy link
Contributor

ahmedre commented Aug 23, 2017

Deployed to: http://staging.quran.com:32933

@thabti thabti self-requested a review August 23, 2017 22:28
@ahmedre
Copy link
Contributor

ahmedre commented Aug 23, 2017

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]]}
Copy link
Contributor

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.

https://github.com/imadmk/quran.com-frontend/blob/f178b4c43fae01bd3f549d8c12aaa0c167943346/src/containers/Surah/index.js#L497

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naveed-ahmad
Copy link
Contributor

@imadmk like I said currentVerse should never be undefined. Issue was here:

https://github.com/quran/quran.com-frontend/pull/863/files#diff-9ec2abb67e828439c94d539294298ec5L25

Fixed. And closing this.

@imadmk
Copy link
Contributor Author

imadmk commented Sep 21, 2017

I see. Great it fixed. Because that will fix many UI flows.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants