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

Commit

Permalink
fixed reading mode (#746)
Browse files Browse the repository at this point in the history
* fixed reading mode

* lint
  • Loading branch information
naveed-ahmad authored and mmahalwy committed Apr 19, 2017
1 parent 39ba4cf commit 230eaf5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/Audioplayer/RepeatDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RepeatButton extends Component {
value={repeat.from}
onChange={(event) => {
let to = parseInt(event.target.value, 10) + 3;
to = to < chapter.ayat ? to : chapter.ayat;
to = to < chapter.versesCount ? to : chapter.versesCount;
setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
Expand All @@ -71,7 +71,7 @@ class RepeatButton extends Component {
>
{
array.reduce((options, ayah, index) => {
if (index + 1 < chapter.ayat) { // Exclude last verse
if (index + 1 < chapter.versesCount) { // Exclude last verse
options.push(
<option key={index} value={index + 1}>
{index + 1}
Expand All @@ -97,7 +97,7 @@ class RepeatButton extends Component {
>
{
array.reduce((options, ayah, index) => {
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= chapter.ayat) {
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= chapter.versesCount) { // eslint-disable-line max-len
options.push(
<option key={index} value={index + 1}>
{index + 1}
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,17 @@ function mapStateToProps(state, ownProps) {
const verseIds = new Set(verseArray);
const lastAyahInArray = verseArray.slice(-1)[0];
const isSingleAyah = !!ownProps.params.range && !ownProps.params.range.includes('-');

const currentVerse = state.audioplayer.currentVerse || Object.keys(verses)[0];

return {
chapter,
verses,
verseIds,
isSingleAyah,
currentVerse,
info: state.chapters.infos[ownProps.params.chapterId],
isStarted: state.audioplayer.isStarted,
isPlaying: state.audioplayer.isPlaying,
currentVerse: state.audioplayer.currentVerse,
isAuthenticated: state.auth.loaded,
currentWord: state.verses.currentWord,
isEndOfSurah: lastAyahInArray === chapter.versesCount,
Expand Down
12 changes: 6 additions & 6 deletions src/redux/modules/lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ export default function reducer(state = initialState, action = {}) {
const ayah = ayahs[ayahId];

ayah.words.forEach((word) => {
if (lines[`${word.pageNum}-${word.lineNum}`]) {
const isInArray = lines[`${word.pageNum}-${word.lineNum}`].find((item) => {
const itemChecksum = `${item.lineNum}${item.code}${item.verseKey}${item.position}`;
const dataChecksum = `${word.lineNum}${word.code}${word.verseKey}${item.position}`;
if (lines[`${word.pageNumber}-${word.lineNumber}`]) {
const isInArray = lines[`${word.pageNumber}-${word.lineNumber}`].find((item) => {
const itemChecksum = `${item.lineNumber}${item.code}${item.verseKey}${item.position}`;
const dataChecksum = `${word.lineNumber}${word.code}${word.verseKey}${item.position}`;

return itemChecksum === dataChecksum;
});

if (!isInArray) {
lines[`${word.pageNum}-${word.lineNum}`].push(word);
lines[`${word.pageNumber}-${word.lineNumber}`].push(word);
}
} else {
lines[`${word.pageNum}-${word.lineNum}`] = [word];
lines[`${word.pageNumber}-${word.lineNumber}`] = [word];
}
});
});
Expand Down

0 comments on commit 230eaf5

Please sign in to comment.