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

Fix non existant ayat #708

Merged
merged 9 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 5 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
13 changes: 12 additions & 1 deletion src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (<div className="text-center">
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: should this be named AyahNotFound to tally with the message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

<h2><LocaleFormattedMessage id="chapter.index.ayahNotFound" defaultMessage="Ayah not found." /></h2>
</div>
);

return isLoading ? <Loader isActive style={LoaderStyle} /> : noAyah;
}

renderPagination() {
const { isSingleAyah, isLoading, isEndOfSurah, chapter } = this.props;

Expand Down Expand Up @@ -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 <div className={style.container} style={{ margin: '50px auto' }}><Loader isActive style={LoaderStyle} /></div>;
if (!this.hasAyahs()) return <div className={style.container} style={{ margin: '50px auto' }}>{this.renderNoAyah()}</div>;

return (
<div className="chapter-body">
Expand Down
14 changes: 8 additions & 6 deletions src/helpers/buildSegments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== undefined) {
Object.values(verses).forEach((verse) => {
if (verse.audio) {
if (verse.audio.segments) {
segments[verse.verseKey] = buildSegments(verse.audio.segments);
}
}
}
});
});
}

return segments;
};
4 changes: 3 additions & 1 deletion src/locale/ar.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
'nav.navigate': 'انتقل',
'nav.legacySite': 'الموقع القديم',

'login.message': 'تسجيل الدخول إلى Quran.com لتخزين كل ما تبذلونه من العناوين والملاحظات والأنشطة.'
'login.message': 'تسجيل الدخول إلى Quran.com لتخزين كل ما تبذلونه من العناوين والملاحظات والأنشطة.',

'chapter.index.ayahNotFound': 'لم يتم العثور على الآية'
}
};
4 changes: 3 additions & 1 deletion src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
'nav.navigate': 'Navigate',
'nav.legacySite': 'Legacy Quran.com',

'login.message': 'Sign in to Quran.com to store all your bookmarks, notes, and activities.'
'login.message': 'Sign in to Quran.com to store all your bookmarks, notes, and activities.',

'chapter.index.ayahNotFound': 'Ayah not found'
}
};
4 changes: 3 additions & 1 deletion src/locale/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export default {
'nav.navigate': 'Naviguer',
'nav.legacySite': 'Version précédente de Quran.com',

'login.message': 'Identifiez-vous sur Quran.com pour enregistrer tous vos favoris, notes et activités. '
'login.message': 'Identifiez-vous sur Quran.com pour enregistrer tous vos favoris, notes et activités. ',

'chapter.index.ayahNotFound': 'Verset introuvable'
}
};

4 changes: 3 additions & 1 deletion src/locale/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
'nav.navigate': 'Telusuri',
'nav.legacySite': 'Quran.com versi lama',

'login.message': 'Masuk ke Quran.com untuk menyimpan semua penanda, catatan, dan aktivitas Anda.'
'login.message': 'Masuk ke Quran.com untuk menyimpan semua penanda, catatan, dan aktivitas Anda.',

'chapter.index.ayahNotFound': 'Ayat tidak ditemukan'
}
};
4 changes: 3 additions & 1 deletion src/locale/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
'nav.navigate': 'Bağlantılar', // there is no exact translation for Navigate in Turkish
'nav.legacySite': 'Eski Siteye Git Quran.com',

'login.message': 'Tüm yer işaretlerinizi, notlarınızı ve etkinliklerinizi saklamak için Quran.com\'a giriş yapın.'
'login.message': 'Tüm yer işaretlerinizi, notlarınızı ve etkinliklerinizi saklamak için Quran.com\'a giriş yapın.',

'chapter.index.ayahNotFound': 'Ayet bulunamadı'
Copy link
Contributor

Choose a reason for hiding this comment

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

ayah.notFound is more appropriate key for this IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

}
};
4 changes: 3 additions & 1 deletion src/locale/ur.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
'nav.navigate': 'تشریف لے جائیں',
'nav.legacySite': 'پرانی سائٹ',

'login.message': 'Quran.com کرنے کیلئے سائن ان سب کو اپنے بک مارکس، نوٹوں اور سرگرمیوں کو ذخیرہ کرنے.'
'login.message': 'Quran.com کرنے کیلئے سائن ان سب کو اپنے بک مارکس، نوٹوں اور سرگرمیوں کو ذخیرہ کرنے.',

'chapter.index.ayahNotFound': 'آیت نہیں ملا'
}
};
14 changes: 8 additions & 6 deletions src/redux/modules/fontFaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please should this be if (!verses)? Explicit checks for undefined would miss out on null values.

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

screen shot 2017-03-26 at 7 25 09 pm

no, if(!verses) does not work. I think if we want to catch null and undefined value, we should use this one:

if (verses !== undefined && verses !== null)

Copy link
Contributor

Choose a reason for hiding this comment

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

if(verses) {
...
}

should be enough, it will check for null, undefined and falsey

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 44e74c2

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,
Expand Down