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
removed duplicated code
  • Loading branch information
naveed-ahmad committed Jan 10, 2017
commit 3dddab0cf9f266d2dfcf7af96a6939269b05442b
36 changes: 9 additions & 27 deletions src/components/Ayah/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ export default class Ayah extends Component {
play();
}

handleWordClick(word){

const { isCurrentAyah, audioActions, isSearched, isPlaying } = this.props;



if(isSearched || !audioActions.setCurrentWord)

return;



if(isCurrentAyah && isPlaying) {

audioActions.setCurrentWord(word.dataset.key)
;
}
 else {
audioActions.setAyah(word.dataset.ayah);
audioActions.playCurrentWord(word.dataset.key);
}

}

renderTranslations() {
const { ayah, match } = this.props;

Expand Down Expand Up @@ -161,23 +147,19 @@ export default class Ayah extends Component {
);
}

buildTooltip(word, tooltip){
let title;

if (!word.wordId) {
title = `Verse ${word.ayahKey.split(':')[1]}`;
} else {
title = word[tooltip];
}
return title;
}

renderText() {
const { ayah, tooltip, currentAyah, isPlaying, audioActions} = this.props;
const { ayah, tooltip, currentAyah, isPlaying, audioActions, isSearched} = this.props;

const text = ayah.words.map(word => {
return(
<Word word={word} currentAyah={currentAyah} tooltip={tooltip} isPlaying={isPlaying} audioActions={audioActions}/>
<Word
word={word}
currentAyah={currentAyah}
tooltip={tooltip}
isPlaying={isPlaying}
audioActions={audioActions}
isSearched={isSearched}
/>
)
});

Expand Down
6 changes: 4 additions & 2 deletions src/components/Word/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default class Line extends React.Component {
audioActions: PropTypes.object.isRequired,
word: PropTypes.object.isRequired,
currentAyah: PropTypes.object.isRequired,
isPlaying: PropTypes.bool
isPlaying: PropTypes.bool,
isSearched: PropTypes.bool
};

buildTooltip(word, tooltip){
Expand All @@ -31,7 +32,8 @@ export default class Line extends React.Component {
}

handleWordClick(word){
const { currentAyah, audioActions, isPlaying } = this.props;
const { currentAyah, audioActions, isPlaying, isSearched } = this.props;
if(isSearched) return;

if(currentAyah == word.ayahKey && isPlaying) {
audioActions.setCurrentWord(word.dataset.key)
;
Expand Down