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

Commit 002845b

Browse files
authored
V3 API (#633)
* changes * work homepage * fix surah * Fix linting * chapter for repeat dropdown
1 parent 20d92dc commit 002845b

File tree

71 files changed

+608
-793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+608
-793
lines changed

src/components/Audioplayer/RepeatDropdown/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const style = require('../style.scss');
1515

1616
class RepeatButton extends Component {
1717
static propTypes = {
18-
surah: surahType,
18+
chapter: surahType,
1919
repeat: PropTypes.shape({
2020
from: PropTypes.number,
2121
to: PropTypes.number,
@@ -57,8 +57,8 @@ class RepeatButton extends Component {
5757
}
5858

5959
renderRangeAyahs() {
60-
const { surah, repeat, setRepeat } = this.props;
61-
const array = Array(surah.ayat).join().split(',');
60+
const { chapter, repeat, setRepeat } = this.props;
61+
const array = Array(chapter.versesCount).join().split(',');
6262

6363
return (
6464
<div className="col-md-12" style={{ paddingTop: 15 }}>
@@ -74,7 +74,7 @@ class RepeatButton extends Component {
7474
value={repeat.from}
7575
onChange={(event) => {
7676
let to = parseInt(event.target.value, 10) + 3;
77-
to = to < surah.ayat ? to : surah.ayat;
77+
to = to < chapter.ayat ? to : chapter.ayat;
7878
setRepeat({
7979
...repeat,
8080
from: parseInt(event.target.value, 10),
@@ -84,7 +84,7 @@ class RepeatButton extends Component {
8484
>
8585
{
8686
array.reduce((options, ayah, index) => {
87-
if (index + 1 < surah.ayat) { // Exclude last verse
87+
if (index + 1 < chapter.ayat) { // Exclude last verse
8888
options.push(
8989
<option key={index} value={index + 1}>
9090
{index + 1}
@@ -110,7 +110,7 @@ class RepeatButton extends Component {
110110
>
111111
{
112112
array.reduce((options, ayah, index) => {
113-
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= surah.ayat) {
113+
if ((repeat.from ? repeat.from : 1) < index + 1 && index + 1 <= chapter.ayat) {
114114
options.push(
115115
<option key={index} value={index + 1}>
116116
{index + 1}
@@ -128,13 +128,13 @@ class RepeatButton extends Component {
128128
}
129129

130130
renderSingleAyah() {
131-
const { repeat, setRepeat, surah } = this.props;
132-
const array = Array(surah.ayat).join().split(',');
131+
const { repeat, setRepeat, chapter } = this.props;
132+
const array = Array(chapter.versesCount).join().split(',');
133133

134134
return (
135135
<div className="col-md-12" style={{ paddingTop: 15 }}>
136136
<LocaleFormattedMessage
137-
id="player.currentAyah"
137+
id="player.currentVerse"
138138
defaultMessage="Ayah"
139139
/>{' '}: <br />
140140
<FormControl

src/components/Audioplayer/RepeatDropdown/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import RepeatDropdown from './index';
66
let component;
77
let overlay;
88
let setRepeat;
9-
const surah = {
9+
const chapter = {
1010
ayat: 10
1111
};
1212

@@ -18,7 +18,7 @@ const makeComponent = (repeat) => {
1818
repeat={repeat}
1919
setRepeat={setRepeat}
2020
current={1}
21-
surah={surah}
21+
chapter={chapter}
2222
/>
2323
);
2424

src/components/Audioplayer/Segments/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import debug from 'helpers/debug';
77
export default class Segments extends Component {
88
static propTypes = {
99
segments: PropTypes.objectOf(segmentType).isRequired,
10-
currentAyah: PropTypes.string,
10+
currentVerse: PropTypes.string,
1111
currentTime: PropTypes.number
1212
};
1313

1414
shouldComponentUpdate(nextProps) {
1515
return [
16-
this.props.currentAyah !== nextProps.currentAyah,
16+
this.props.currentVerse !== nextProps.currentVerse,
1717
this.props.currentTime !== nextProps.currentTime,
1818
].some(test => test);
1919
}
2020

2121
render() {
22-
const { segments, currentAyah, currentTime } = this.props;
22+
const { segments, currentVerse, currentTime } = this.props;
2323
const style = [];
2424
let currentWord = null;
2525

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

3131
if (currentTime >= word.startTime && currentTime < word.endTime) {
32-
currentWord = `${currentAyah}:${wordIndex}`;
32+
currentWord = `${currentVerse}:${wordIndex}`;
3333
}
3434
});
3535

src/components/Audioplayer/Segments/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('<Segments />', () => {
2929
<Segments
3030
segments={{ words: { 0: { startTime: 0, endTime: 1 }, 1: { startTime: 1, endTime: 2 } } }}
3131
currentTime={1.5}
32-
currentAyah="1:1"
32+
currentVerse="1:1"
3333
/>
3434
);
3535
});
@@ -64,7 +64,7 @@ describe('<Segments />', () => {
6464
}
6565
}}
6666
currentTime={1.5}
67-
currentAyah="1:1"
67+
currentVerse="1:1"
6868
/>
6969
);
7070
});

0 commit comments

Comments
 (0)