Skip to content

Commit

Permalink
feat: Search for better works now on the my episodes screen
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Mar 6, 2019
1 parent 1773ba8 commit 6b4e08c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/screens/MyEpisodes/MyEpisodesContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as HomeSelectors from '../Home/HomeSelectors'
import MyEpisodes from './MyEpisodesScreen'

export const mapStateToProps = state => ({
modes: HomeSelectors.getModes(state),
myEpisodes: HomeSelectors.getModes(state).myEpisodes,
})

export default connect(mapStateToProps, HomeActions)(MyEpisodes)
16 changes: 14 additions & 2 deletions app/screens/MyEpisodes/MyEpisodesScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const styles = StyleSheet.create({

export class MyEpisodes extends React.PureComponent {

static getDerivedStateFromProps(props) {
static getDerivedStateFromProps(props, state) {
// If we are not focused cancel the quality selector
if (!props.isFocused) {
return {
Expand All @@ -71,6 +71,18 @@ export class MyEpisodes extends React.PureComponent {
}
}

const { episodeToPlay, selectFromTorrents } = state

if (episodeToPlay && selectFromTorrents) {
const { myEpisodes: { items } } = props

const newEpisode = items.find(item => item.id === episodeToPlay.id)

return {
selectFromTorrents: newEpisode ? newEpisode.torrents : selectFromTorrents,
}
}

return {}
}

Expand Down Expand Up @@ -186,7 +198,7 @@ export class MyEpisodes extends React.PureComponent {
)

render() {
const { modes: { myEpisodes: { items, refreshing, fetching } } } = this.props
const { myEpisodes: { items, refreshing, fetching } } = this.props
const { selectFromTorrents, episodeToPlay } = this.state

return (
Expand Down

0 comments on commit 6b4e08c

Please sign in to comment.