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

Fixes for repeat range bugs #644

Merged
merged 3 commits into from
Feb 9, 2017
Merged
Changes from all 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
44 changes: 29 additions & 15 deletions src/components/Audioplayer/RepeatDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,27 @@ class RepeatButton extends Component {
<FormControl
componentClass="select"
value={repeat.from}
onChange={event => setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
to: parseInt(event.target.value, 10) + 3
})}
onChange={(event) => {
let to = parseInt(event.target.value, 10) + 3;
to = to < surah.ayat ? to : surah.ayat;
setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
to
});
}}
>
{
array.map((ayah, index) => (
<option key={index} value={index + 1}>
{index + 1}
</option>
))
array.reduce((options, ayah, index) => {
if (index + 1 < surah.ayat) { // Exclude last verse
options.push(
<option key={index} value={index + 1}>
{index + 1}
</option>
);
}
return options;
}, [])
}
</FormControl>
</li>
Expand All @@ -100,11 +109,16 @@ class RepeatButton extends Component {
onChange={event => setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })}
>
{
array.map((ayah, index) => (
<option key={index} value={repeat.from ? index + 1 + repeat.from : index + 1}>
{repeat.from ? index + 1 + repeat.from : index + 1}
</option>
))
array.reduce((options, ayah, index) => {
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= surah.ayat) {
options.push(
<option key={index} value={index + 1}>
{index + 1}
</option>
);
}
return options;
}, [])
}
</FormControl>
</li>
Expand Down