From dbb948934eddc660d31be47c6533c40e6d779cb6 Mon Sep 17 00:00:00 2001 From: Jawad Khokhar Date: Thu, 9 Feb 2017 09:10:09 +0000 Subject: [PATCH] Fixes for repeat range bugs (#644) * Fix 'from' onChange * Fix available 'to' options * Fix available 'from' options --- .../Audioplayer/RepeatDropdown/index.js | 44 ++++++++++++------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/components/Audioplayer/RepeatDropdown/index.js b/src/components/Audioplayer/RepeatDropdown/index.js index 22ae916be..b5ff5d1db 100644 --- a/src/components/Audioplayer/RepeatDropdown/index.js +++ b/src/components/Audioplayer/RepeatDropdown/index.js @@ -72,18 +72,27 @@ class RepeatButton extends Component { 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) => ( - - )) + array.reduce((options, ayah, index) => { + if (index + 1 < surah.ayat) { // Exclude last verse + options.push( + + ); + } + return options; + }, []) } @@ -100,11 +109,16 @@ class RepeatButton extends Component { onChange={event => setRepeat({ ...repeat, to: parseInt(event.target.value, 10) })} > { - array.map((ayah, index) => ( - - )) + array.reduce((options, ayah, index) => { + if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= surah.ayat) { + options.push( + + ); + } + return options; + }, []) }