Skip to content

Commit

Permalink
feat: Search for qualities available when there was nothing at all
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed Mar 6, 2019
1 parent 6b4e08c commit 7a148e0
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 28 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
46 changes: 30 additions & 16 deletions app/components/QualitySelector/QualitySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -74,7 +75,7 @@ export default class QualitySelector extends React.Component {
}

static defaultProps = {
myEpisodesScreen:false,
myEpisodesScreen: false,
}

state = {
Expand Down Expand Up @@ -113,7 +114,7 @@ export default class QualitySelector extends React.Component {
: item,

episodeToPlay,
myEpisodesScreen
myEpisodesScreen,
)
}

Expand Down Expand Up @@ -161,25 +162,38 @@ export default class QualitySelector extends React.Component {
<Button
onPress={this.handleSearchForBetter}
variant={'primary'}>
{i18n.t('search for better')}
{qualities.length > 0
? i18n.t('search for better')
: i18n.t('search for qualities')
}
</Button>
</View>

{qualities.length === 0 && (
<Typography variant={'title'}>
{i18n.t('No qualities available! Try to search')}
</Typography>
)}

{qualities.map((quality) => (
<BaseButton
<Animatable.View
key={quality}
onPress={() => this.playQuality(quality)}>
<Text style={[
styles.quality,
{
borderBottomColor: torrents
? torrents[quality].health.color
: null,
},
]}>
{quality}
</Text>
</BaseButton>
animation={'fadeIn'}
duration={200}
useNativeDriver>
<BaseButton onPress={() => this.playQuality(quality)}>
<Text style={[
styles.quality,
{
borderBottomColor: torrents
? torrents[quality].health.color
: null,
},
]}>
{quality}
</Text>
</BaseButton>
</Animatable.View>
))}
</View>
)}
Expand Down
4 changes: 3 additions & 1 deletion app/modules/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 3 additions & 1 deletion app/modules/i18n/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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 (
Expand All @@ -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} />
)}

Expand Down
19 changes: 18 additions & 1 deletion app/screens/Item/ItemScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -136,7 +153,7 @@ export default class Item extends React.PureComponent {

navigate('Player', {
torrent,
item: playItem
item: playItem,
})
}

Expand Down
2 changes: 1 addition & 1 deletion app/screens/MyEpisodes/MyEpisodesScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit 7a148e0

Please sign in to comment.