From 66b8a2e05c004ad872b923fccf5695b57b709dae Mon Sep 17 00:00:00 2001 From: Aslam Hadi H Date: Wed, 29 Mar 2017 01:46:52 +0700 Subject: [PATCH] Fix non existant ayat (#708) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix page when ayat not found * refactor previous commit * add translation for ‘chapter.index.ayatNotFound’ * fix typo * refactor verses checker * change key in translation * update ar translation --- src/containers/Surah/index.js | 13 ++++++++++++- src/helpers/buildSegments.js | 14 ++++++++------ src/locale/ar.js | 4 +++- src/locale/en.js | 1 + src/locale/fr.js | 1 + src/locale/id.js | 1 + src/locale/tr.js | 1 + src/locale/ur.js | 1 + src/redux/modules/fontFaces.js | 14 ++++++++------ 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/containers/Surah/index.js b/src/containers/Surah/index.js index e9a0322db..0067c965b 100644 --- a/src/containers/Surah/index.js +++ b/src/containers/Surah/index.js @@ -225,6 +225,17 @@ class Surah extends Component { return `${chapter.info ? chapter.info.shortDescription : ''} This Surah has ${chapter.versesCount} verses and resides between pages ${chapter.pages[0]} to ${chapter.pages[1]} in the Quran.`; // eslint-disable-line max-len } + renderNoAyah() { + const { isLoading } = this.props; + + const noAyah = (
+

+
+ ); + + return isLoading ? : noAyah; + } + renderPagination() { const { isSingleAyah, isLoading, isEndOfSurah, chapter } = this.props; @@ -341,7 +352,7 @@ class Surah extends Component { const { chapter, options, actions } = this.props; // eslint-disable-line no-shadow debug('component:Surah', 'Render'); - if (!this.hasAyahs()) return
; + if (!this.hasAyahs()) return
{this.renderNoAyah()}
; return (
diff --git a/src/helpers/buildSegments.js b/src/helpers/buildSegments.js index d04beb5f6..eb77b0602 100644 --- a/src/helpers/buildSegments.js +++ b/src/helpers/buildSegments.js @@ -24,13 +24,15 @@ export const buildSegments = (segments) => { export const extractSegments = (verses) => { const segments = {}; - Object.values(verses).forEach((verse) => { - if (verse.audio) { - if (verse.audio.segments) { - segments[verse.verseKey] = buildSegments(verse.audio.segments); + if (verses) { + Object.values(verses).forEach((verse) => { + if (verse.audio) { + if (verse.audio.segments) { + segments[verse.verseKey] = buildSegments(verse.audio.segments); + } } - } - }); + }); + } return segments; }; diff --git a/src/locale/ar.js b/src/locale/ar.js index 7a7800367..b32e956d2 100644 --- a/src/locale/ar.js +++ b/src/locale/ar.js @@ -76,6 +76,8 @@ export default { 'nav.navigate': 'انتقل', 'nav.legacySite': 'الموقع القديم', - 'login.message': 'تسجيل الدخول إلى Quran.com لتخزين كل ما تبذلونه من العناوين والملاحظات والأنشطة.' + 'login.message': 'تسجيل الدخول إلى Quran.com لتخزين كل ما تبذلونه من العناوين والملاحظات والأنشطة.', + + 'ayah.notFound': 'لم يتم العثور على الآية' } }; diff --git a/src/locale/en.js b/src/locale/en.js index ef3d60c4b..06867da2a 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -28,6 +28,7 @@ export default { 'ayah.media.lectureFrom': 'Watch video commentary from {from}', 'ayah.bookmarked': 'Bookmarked', 'ayah.bookmark': 'Bookmark', + 'ayah.notFound': 'Ayah not found', 'search.placeholder': 'Search "Noah"', 'search.resultHeading': '{from}-{to} OF {total} SEARCH RESULTS FOR: {query}', // eslint-disable-line max-len diff --git a/src/locale/fr.js b/src/locale/fr.js index 01f5d1ed7..02bdebbd7 100644 --- a/src/locale/fr.js +++ b/src/locale/fr.js @@ -28,6 +28,7 @@ export default { 'ayah.media.lectureFrom': 'Regarder les commentaires de la vidéo depuis {from}', 'ayah.bookmarked': 'Favoris ajouté', 'ayah.bookmark': 'Favoris', + 'ayah.notFound': 'Verset introuvable', 'search.placeholder': 'Chercher "Noah"', 'search.resultHeading': '{from}-{to} DE {total} RESULTATS DE LA RECHERCHE POUR : {query}', // eslint-disable-line max-len diff --git a/src/locale/id.js b/src/locale/id.js index a5b13192e..4c66401d0 100644 --- a/src/locale/id.js +++ b/src/locale/id.js @@ -28,6 +28,7 @@ export default { 'ayah.media.lectureFrom': 'Lihat kuliah dari {from}', 'ayah.bookmarked': 'Ditandai', 'ayah.bookmark': 'Tandai', + 'ayah.notFound': 'Ayat tidak ditemukan', 'search.placeholder': 'Cari "Nuh"', 'search.resultHeading': '{from}-{to} DARI {total} HASIL PENCARIAN ATAS: {query}', // eslint-disable-line max-len diff --git a/src/locale/tr.js b/src/locale/tr.js index e0fb8f9ef..3c6007e6c 100644 --- a/src/locale/tr.js +++ b/src/locale/tr.js @@ -28,6 +28,7 @@ export default { 'ayah.media.lectureFrom': 'Video anlatımı izle {from}', 'ayah.bookmarked': 'Yer işareti eklendi', 'ayah.bookmark': 'Yer işareti', + 'ayah.notFound': 'Ayet bulunamadı', 'search.placeholder': 'Arama yap "Nuh"', 'search.resultHeading': '{from}-{to} / {total} ARAMA SONUÇLARI: {query}', // eslint-disable-line max-len diff --git a/src/locale/ur.js b/src/locale/ur.js index 95fac6e0d..856c6e998 100644 --- a/src/locale/ur.js +++ b/src/locale/ur.js @@ -28,6 +28,7 @@ export default { 'ayah.media.lectureFrom': 'کے لیکچر دیکھے {from}', 'ayah.bookmarked': 'حوالہ ہے', 'ayah.bookmark': 'حوالہ', + 'ayah.notFound': 'آیت نہیں ملا', 'search.placeholder': 'تلاش کر یں', 'search.resultHeading': '{from}-{to} OF {total} SEARCH RESULTS FOR: {query}', // eslint-disable-line max-len diff --git a/src/redux/modules/fontFaces.js b/src/redux/modules/fontFaces.js index 07e59d857..73a72947c 100644 --- a/src/redux/modules/fontFaces.js +++ b/src/redux/modules/fontFaces.js @@ -9,13 +9,15 @@ export default function reducer(state = {}, action = {}) { const verses = action.result.entities.verses; const classNames = {}; - Object.keys(verses).forEach((ayahId) => { - const verse = verses[ayahId]; + if (verses) { + Object.keys(verses).forEach((ayahId) => { + const verse = verses[ayahId]; - if (!state[`p${verse.pageNumber}`]) { - classNames[`p${verse.pageNumber}`] = false; - } - }); + if (!state[`p${verse.pageNumber}`]) { + classNames[`p${verse.pageNumber}`] = false; + } + }); + } return { ...state,