From 7a148e083e3576c9e7407ccb433b8f6eb3dd8796 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Wed, 6 Mar 2019 17:23:43 +0100 Subject: [PATCH] feat: Search for qualities available when there was nothing at all --- android/app/build.gradle | 4 +- .../QualitySelector/QualitySelector.js | 46 ++++++++++++------- app/modules/i18n/translations/en.json | 4 +- app/modules/i18n/translations/nl.json | 4 +- .../SeasonsAndEpisodes/Episode/Episode.js | 10 ++-- app/screens/Item/ItemScreen.js | 19 +++++++- app/screens/MyEpisodes/MyEpisodesScreen.js | 2 +- 7 files changed, 61 insertions(+), 28 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index a802768..3111e6f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -122,8 +122,8 @@ android { applicationId "com.popcorn" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 19 - versionName "v0.14.0" + versionCode 20 + versionName "v0.15.0" ndk { abiFilters "armeabi-v7a", "x86" } diff --git a/app/components/QualitySelector/QualitySelector.js b/app/components/QualitySelector/QualitySelector.js index fde56de..6b3956e 100644 --- a/app/components/QualitySelector/QualitySelector.js +++ b/app/components/QualitySelector/QualitySelector.js @@ -8,6 +8,7 @@ import i18n from 'modules/i18n' import BaseButton from 'components/BaseButton' import Button from 'components/Button' import IconButton from 'components/IconButton' +import Typography from 'components/Typography' import colors from 'modules/colors' @@ -74,7 +75,7 @@ export default class QualitySelector extends React.Component { } static defaultProps = { - myEpisodesScreen:false, + myEpisodesScreen: false, } state = { @@ -113,7 +114,7 @@ export default class QualitySelector extends React.Component { : item, episodeToPlay, - myEpisodesScreen + myEpisodesScreen, ) } @@ -161,25 +162,38 @@ export default class QualitySelector extends React.Component { + {qualities.length === 0 && ( + + {i18n.t('No qualities available! Try to search')} + + )} + {qualities.map((quality) => ( - this.playQuality(quality)}> - - {quality} - - + animation={'fadeIn'} + duration={200} + useNativeDriver> + this.playQuality(quality)}> + + {quality} + + + ))} )} diff --git a/app/modules/i18n/translations/en.json b/app/modules/i18n/translations/en.json index ae72c55..c5679a8 100644 --- a/app/modules/i18n/translations/en.json +++ b/app/modules/i18n/translations/en.json @@ -30,5 +30,7 @@ "Episodes aired within the last 7 days from shows you follow will appear here": "Episodes aired within the last 7 days from shows you follow will appear here", "Subtitles": "Subtitles", "None": "None", - "search for better": "search for better" + "search for better": "search for better", + "search for qualities": "search for qualities", + "No qualities available! Try to search": "No qualities available! Try to search" } diff --git a/app/modules/i18n/translations/nl.json b/app/modules/i18n/translations/nl.json index afe2d06..3020c7c 100644 --- a/app/modules/i18n/translations/nl.json +++ b/app/modules/i18n/translations/nl.json @@ -30,5 +30,7 @@ "Episodes aired within the last 7 days from shows you follow will appear here": "Afleveringen die de afgelopen 7 dagen uitgekomen zijn van series die je volgt komen hier", "Subtitles": "Ondertiteling", "None": "Geen", - "search for better": "zoek naar betere" + "search for better": "zoek naar betere", + "search for qualities": "zoeken", + "No qualities available! Try to search": "Niks beschikbaar! Probeer zoeken" } diff --git a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js index 3a51163..ae9994b 100644 --- a/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js +++ b/app/screens/Item/ItemOrRecommendations/SeasonsAndEpisodes/Episode/Episode.js @@ -72,9 +72,7 @@ export default class Episode extends React.Component { handlePlayItem = () => { const { playItem, ...episode } = this.props - if (episode.hasTorrents) { - playItem(episode.torrents, this.props) - } + playItem(episode.torrents, this.props) } getAirsDate = () => { @@ -87,7 +85,7 @@ export default class Episode extends React.Component { } render() { - const { hasTorrents, title, summary, number, images, hasAired } = this.props + const { title, summary, number, images, hasAired } = this.props const { showPlaceholder } = this.props return ( @@ -113,8 +111,8 @@ export default class Episode extends React.Component { iconStyle={{ margin: 0 }} backgroundColor={'transparent'} borderRadius={0} - name={hasTorrents ? 'play-circle-outline' : 'cancel'} - color={hasTorrents ? '#FFF' : 'red'} + name={'play-circle-outline'} + color={'#FFF'} size={60} /> )} diff --git a/app/screens/Item/ItemScreen.js b/app/screens/Item/ItemScreen.js index db7bbdf..98b4a05 100644 --- a/app/screens/Item/ItemScreen.js +++ b/app/screens/Item/ItemScreen.js @@ -49,6 +49,23 @@ export default class Item extends React.PureComponent { episodeToPlay : null, } + static getDerivedStateFromProps(props, state) { + const { episodeToPlay, selectFromTorrents } = state + + if (episodeToPlay && selectFromTorrents) { + const { item } = props + + const season = item.seasons.find(season => season.number === episodeToPlay.season) + const newEpisode = season.episodes.find(episode => episode.number === episodeToPlay.number) + + return { + selectFromTorrents: newEpisode ? newEpisode.torrents : selectFromTorrents, + } + } + + return {} + } + componentDidMount() { Orientation.lockToPortrait() @@ -136,7 +153,7 @@ export default class Item extends React.PureComponent { navigate('Player', { torrent, - item: playItem + item: playItem, }) } diff --git a/app/screens/MyEpisodes/MyEpisodesScreen.js b/app/screens/MyEpisodes/MyEpisodesScreen.js index 25a428d..d4b599b 100644 --- a/app/screens/MyEpisodes/MyEpisodesScreen.js +++ b/app/screens/MyEpisodes/MyEpisodesScreen.js @@ -77,7 +77,7 @@ export class MyEpisodes extends React.PureComponent { const { myEpisodes: { items } } = props const newEpisode = items.find(item => item.id === episodeToPlay.id) - + return { selectFromTorrents: newEpisode ? newEpisode.torrents : selectFromTorrents, }