From 0d4056c76d49f3ac25995f2bfc8613ae10e5d5cb Mon Sep 17 00:00:00 2001 From: Aslam Hadi H Date: Fri, 9 Dec 2016 20:32:32 +0700 Subject: [PATCH] fix surah still display Loading even in last of surah (#521) --- src/containers/Surah/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/containers/Surah/index.js b/src/containers/Surah/index.js index 5c07429b4..aff966ba9 100644 --- a/src/containers/Surah/index.js +++ b/src/containers/Surah/index.js @@ -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, @@ -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,