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

Commit

Permalink
Fixes for repeat range bugs (#644)
Browse files Browse the repository at this point in the history
* Fix 'from' onChange

* Fix available 'to' options

* Fix available 'from' options
  • Loading branch information
jawadkho authored and mmahalwy committed Feb 9, 2017
1 parent c8f5a85 commit dbb9489
Showing 1 changed file with 29 additions and 15 deletions.
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

0 comments on commit dbb9489

Please sign in to comment.