This repository was archived by the owner on Jun 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
#383 Ayah Play Audio + Redux Refactoring (WIP) #390
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0def82e
#383 refactoring how redux actions and fixing ayah play (WIP)
thabti c5622b1
383 lint-roller :bowtie:
thabti 6206412
#383 refactor out decorators.
thabti f0792a5
#383 hide play from search results.
thabti 5aaa2b3
#371 lint-roller :bowtie:
thabti 81d09b2
#371 :scissors
thabti 907790f
#371 :scissors:
thabti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,13 @@ export default class Ayah extends Component { | |
| isSearch: PropTypes.bool, | ||
| tooltip: PropTypes.string, | ||
| currentWord: PropTypes.any, // gets passed in an integer, null by default | ||
| onWordClick: PropTypes.func.isRequired | ||
| onWordClick: PropTypes.func, | ||
| actions: PropTypes.object | ||
| }; | ||
|
|
||
| static defaultProps = { | ||
| currentWord: null, | ||
| isSearched: false, | ||
| isSearched: false | ||
| }; | ||
|
|
||
| shouldComponentUpdate(nextProps) { | ||
|
|
@@ -44,10 +45,14 @@ export default class Ayah extends Component { | |
| return conditions.some(condition => condition); | ||
| } | ||
|
|
||
| handlePlay() { | ||
| this.setState({ | ||
| open: false | ||
| }); | ||
| handlePlay(ayah) { | ||
|
|
||
| const {stop, setAyah, start} = this.props.actions; | ||
|
|
||
| stop(); | ||
| setAyah(ayah); | ||
| start(); | ||
|
|
||
|
||
| } | ||
|
|
||
| renderTranslations() { | ||
|
|
@@ -140,12 +145,12 @@ export default class Ayah extends Component { | |
| } | ||
|
|
||
| renderPlayLink() { | ||
| const { isSearch, ayah } = this.props; | ||
| const { isSearched, ayah } = this.props; | ||
|
|
||
| if (!isSearch) { | ||
| if (!isSearched) { | ||
| return ( | ||
| <a | ||
| onClick={() => this.handlePlay(ayah.ayahNum)} | ||
| onClick={() => this.handlePlay(ayah.ayahKey)} | ||
| className="text-muted" | ||
| > | ||
| <i className="ss-icon ss-play" /> Play | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,7 @@ import FontStyles from 'components/FontStyles'; | |
| const styles = require('./style.scss'); | ||
|
|
||
| @metrics(metricsConfig) | ||
|
||
| @connect( | ||
| state => ({ | ||
| surahs: state.surahs.entities | ||
| }) | ||
| ) | ||
| export default class App extends Component { | ||
| class App extends Component { | ||
| static propTypes = { | ||
| surahs: PropTypes.object, | ||
| children: PropTypes.any | ||
|
|
@@ -107,3 +102,5 @@ export default class App extends Component { | |
| ); | ||
| } | ||
| } | ||
|
|
||
| export default connect(state => ({surahs: state.surahs.entities }))(App) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,18 +11,6 @@ import { isAllLoaded, loadAll } from '../../redux/modules/surahs'; | |
|
|
||
| const styles = require('./style.scss'); | ||
|
|
||
| @asyncConnect([{ | ||
| promise({ store: { getState, dispatch } }) { | ||
| if (!isAllLoaded(getState())) { | ||
| return dispatch(loadAll()); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| }]) | ||
| @connect( | ||
| state => ({surahs: state.surahs.entities}) | ||
| ) | ||
| class Home extends Component { | ||
| static propTypes = { | ||
| lastVisit: PropTypes.any, | ||
|
|
@@ -189,4 +177,16 @@ class Home extends Component { | |
| } | ||
| } | ||
|
|
||
| export default Home; | ||
| const AsyncHome = asyncConnect([{ | ||
| promise({ store: { getState, dispatch } }) { | ||
| if (!isAllLoaded(getState())) { | ||
| return dispatch(loadAll()); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| }])(Home); | ||
|
|
||
|
|
||
|
||
| export default connect(state => ({surahs: state.surahs.entities}))(AsyncHome); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️