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

Commit

Permalink
V3 API (#633)
Browse files Browse the repository at this point in the history
* changes

* work homepage

* fix surah

* Fix linting

* chapter for repeat dropdown
  • Loading branch information
mmahalwy authored Mar 3, 2017
1 parent 20d92dc commit 002845b
Show file tree
Hide file tree
Showing 71 changed files with 608 additions and 793 deletions.
18 changes: 9 additions & 9 deletions src/components/Audioplayer/RepeatDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const style = require('../style.scss');

class RepeatButton extends Component {
static propTypes = {
surah: surahType,
chapter: surahType,
repeat: PropTypes.shape({
from: PropTypes.number,
to: PropTypes.number,
Expand Down Expand Up @@ -57,8 +57,8 @@ class RepeatButton extends Component {
}

renderRangeAyahs() {
const { surah, repeat, setRepeat } = this.props;
const array = Array(surah.ayat).join().split(',');
const { chapter, repeat, setRepeat } = this.props;
const array = Array(chapter.versesCount).join().split(',');

return (
<div className="col-md-12" style={{ paddingTop: 15 }}>
Expand All @@ -74,7 +74,7 @@ class RepeatButton extends Component {
value={repeat.from}
onChange={(event) => {
let to = parseInt(event.target.value, 10) + 3;
to = to < surah.ayat ? to : surah.ayat;
to = to < chapter.ayat ? to : chapter.ayat;
setRepeat({
...repeat,
from: parseInt(event.target.value, 10),
Expand All @@ -84,7 +84,7 @@ class RepeatButton extends Component {
>
{
array.reduce((options, ayah, index) => {
if (index + 1 < surah.ayat) { // Exclude last verse
if (index + 1 < chapter.ayat) { // Exclude last verse
options.push(
<option key={index} value={index + 1}>
{index + 1}
Expand All @@ -110,7 +110,7 @@ class RepeatButton extends Component {
>
{
array.reduce((options, ayah, index) => {
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= surah.ayat) {
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= chapter.ayat) {
options.push(
<option key={index} value={index + 1}>
{index + 1}
Expand All @@ -128,13 +128,13 @@ class RepeatButton extends Component {
}

renderSingleAyah() {
const { repeat, setRepeat, surah } = this.props;
const array = Array(surah.ayat).join().split(',');
const { repeat, setRepeat, chapter } = this.props;
const array = Array(chapter.versesCount).join().split(',');

return (
<div className="col-md-12" style={{ paddingTop: 15 }}>
<LocaleFormattedMessage
id="player.currentAyah"
id="player.currentVerse"
defaultMessage="Ayah"
/>{' '}: <br />
<FormControl
Expand Down
4 changes: 2 additions & 2 deletions src/components/Audioplayer/RepeatDropdown/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import RepeatDropdown from './index';
let component;
let overlay;
let setRepeat;
const surah = {
const chapter = {
ayat: 10
};

Expand All @@ -18,7 +18,7 @@ const makeComponent = (repeat) => {
repeat={repeat}
setRepeat={setRepeat}
current={1}
surah={surah}
chapter={chapter}
/>
);

Expand Down
8 changes: 4 additions & 4 deletions src/components/Audioplayer/Segments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import debug from 'helpers/debug';
export default class Segments extends Component {
static propTypes = {
segments: PropTypes.objectOf(segmentType).isRequired,
currentAyah: PropTypes.string,
currentVerse: PropTypes.string,
currentTime: PropTypes.number
};

shouldComponentUpdate(nextProps) {
return [
this.props.currentAyah !== nextProps.currentAyah,
this.props.currentVerse !== nextProps.currentVerse,
this.props.currentTime !== nextProps.currentTime,
].some(test => test);
}

render() {
const { segments, currentAyah, currentTime } = this.props;
const { segments, currentVerse, currentTime } = this.props;
const style = [];
let currentWord = null;

Expand All @@ -29,7 +29,7 @@ export default class Segments extends Component {
const word = segments.words[wordIndex];

if (currentTime >= word.startTime && currentTime < word.endTime) {
currentWord = `${currentAyah}:${wordIndex}`;
currentWord = `${currentVerse}:${wordIndex}`;
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/components/Audioplayer/Segments/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('<Segments />', () => {
<Segments
segments={{ words: { 0: { startTime: 0, endTime: 1 }, 1: { startTime: 1, endTime: 2 } } }}
currentTime={1.5}
currentAyah="1:1"
currentVerse="1:1"
/>
);
});
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('<Segments />', () => {
}
}}
currentTime={1.5}
currentAyah="1:1"
currentVerse="1:1"
/>
);
});
Expand Down
Loading

0 comments on commit 002845b

Please sign in to comment.