Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ensure play icon next to each ayah works (#415)
  • Loading branch information
thabti authored and mmahalwy committed Jul 27, 2016
commit 8ca18c78fac96002384e99b41290df88e0819c3a
10 changes: 7 additions & 3 deletions src/components/Ayah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class Ayah extends Component {
ayah: PropTypes.object.isRequired,
match: PropTypes.array,
isSearch: PropTypes.bool,
isPlaying: PropTypes.bool,
tooltip: PropTypes.string,
currentWord: PropTypes.any, // gets passed in an integer, null by default
onWordClick: PropTypes.func,
Expand All @@ -46,11 +47,14 @@ export default class Ayah extends Component {
}

handlePlay(ayah) {
const {stop, setAyah, start} = this.props.actions;
const {isPlaying, actions} = this.props;
const {pause, setAyah, play} = actions;

stop();
if (isPlaying) {
pause();
}
setAyah(ayah);
start();
play();
}

renderTranslations() {
Expand Down
8 changes: 5 additions & 3 deletions src/containers/Surah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class Surah extends Component {
options: PropTypes.object.isRequired,
params: PropTypes.object.isRequired,
ayahs: PropTypes.object.isRequired,
isStarted: PropTypes.bool
isStarted: PropTypes.bool,
isPlaying: PropTypes.bool
};

state = {
Expand Down Expand Up @@ -280,14 +281,15 @@ class Surah extends Component {
}

renderAyahs() {
const { ayahs, actions, options } = this.props; // eslint-disable-line no-shadow
const { ayahs, actions, options, isPlaying } = this.props; // eslint-disable-line no-shadow

return Object.values(ayahs).map(ayah => (
<Ayah
ayah={ayah}
tooltip={options.tooltip}
onWordClick={actions.audio.setCurrentWord}
actions={actions.audio}
isPlaying={isPlaying}
key={`${ayah.surahId}-${ayah.ayahNum}-ayah`}
/>
));
Expand Down Expand Up @@ -467,12 +469,12 @@ function mapStateToProps(state, ownProps) {
const surah: Object = state.surahs.entities[surahId];
const ayahs: Object = state.ayahs.entities[surahId];
const ayahIds = new Set(Object.keys(ayahs).map(key => parseInt(key.split(':')[1], 10)));

return {
surah,
ayahs,
ayahIds,
isStarted: state.audioplayer.isStarted,
isPlaying: state.audioplayer.isPlaying,
currentWord: state.ayahs.currentWord,
isEndOfSurah: ayahIds.size === surah.ayat,
surahs: state.surahs.entities,
Expand Down