diff --git a/app/screens/MyEpisodes/MyEpisodesContainer.js b/app/screens/MyEpisodes/MyEpisodesContainer.js index 0274bfb..9c958e0 100644 --- a/app/screens/MyEpisodes/MyEpisodesContainer.js +++ b/app/screens/MyEpisodes/MyEpisodesContainer.js @@ -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) diff --git a/app/screens/MyEpisodes/MyEpisodesScreen.js b/app/screens/MyEpisodes/MyEpisodesScreen.js index 58e5458..25a428d 100644 --- a/app/screens/MyEpisodes/MyEpisodesScreen.js +++ b/app/screens/MyEpisodes/MyEpisodesScreen.js @@ -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 { @@ -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 {} } @@ -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 (