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

Commit

Permalink
fixes the bug where you get a stacktrace when you try to back/forward… (
Browse files Browse the repository at this point in the history
#270)

* fixes the bug where you get a stacktrace when you try to back/forward or jump to an ayah

* another fix
  • Loading branch information
Nour Sharabash authored and mmahalwy committed Apr 8, 2016
1 parent c882a18 commit 370ffaa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Audioplayer/Track/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default class Track extends Component {
};

componentDidMount() {
this.onFileLoad(this.props.file);
if (this.props.file) {
this.onFileLoad(this.props.file);
}
}

componentWillUnmount() {
Expand Down
14 changes: 12 additions & 2 deletions src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,22 @@ export default class Surah extends Component {
if (params.range.includes('-')) {
const [from, to] = params.range.split('-').map(num => parseInt(num, 10));
const array = Array(to - from).fill(from);
const translations = array.map((fromAyah, index) => ayahs[`${surah.id}:${fromAyah + index}`].content[0].text);
const translations = array.map((fromAyah, index) => {
const ayah = ayahs[`${surah.id}:${fromAyah + index}`];
if (ayah && ayah.content && ayah.content[0]) {
return ayah.content[0].text;
}
});
const content = translations.join(' - ').slice(0, 250);

return `Surat ${surah.name.simple} [verse ${params.range}] - ${content}`;
} else {
return `Surat ${surah.name.simple} [verse ${params.range}] - ${ayahs[`${surah.id}:${params.range}`].content[0].text}`;
const ayah = ayahs[`${surah.id}:${params.range}`];
if (ayah && ayah.content && ayah.content[0]) {
return `Surat ${surah.name.simple} [verse ${params.range}] - ${ayah.content[0].text}`;
} else {
return `Surat ${surah.name.simple} [verse ${params.range}]`;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/redux/modules/ayahs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function reducer(state = initialState, action = {}) {
case CLEAR_CURRENT:
return {
...state,
current: null,
entities: {
...state.entities,
[action.id]: {}
Expand Down

0 comments on commit 370ffaa

Please sign in to comment.