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

Fix loading always shows when reaching the end of the surah #521

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ function mapStateToProps(state, ownProps) {
const surahId = parseInt(ownProps.params.surahId, 10);
const surah: Object = state.surahs.entities[surahId];
const ayahs: Object = state.ayahs.entities[surahId];
const ayahIds = new Set(Object.keys(ayahs).map(key => parseInt(key.split(':')[1], 10)));
const ayahArray = Object.keys(ayahs).map(key => parseInt(key.split(':')[1], 10));
const ayahIds = new Set(ayahArray);
const lastAyahInArray = ayahArray.slice(-1)[0];

return {
surah,
Expand All @@ -486,7 +488,7 @@ function mapStateToProps(state, ownProps) {
currentAyah: state.audioplayer.currentAyah,
isAuthenticated: state.auth.loaded,
currentWord: state.ayahs.currentWord,
isEndOfSurah: ayahIds.size === surah.ayat,
isEndOfSurah: lastAyahInArray === surah.ayat,
surahs: state.surahs.entities,
bookmarks: state.bookmarks.entities,
isLoading: state.ayahs.loading,
Expand Down