Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Improvements #27

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 18 additions & 41 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
"extends" : [
"standard",
"standard-react",
"airbnb"
"airbnb",
"plugin:flowtype/recommended",
"plugin:jest/recommended"
],
"plugins": [
"babel",
"react",
"promise",
"jsx-a11y"
"jsx-a11y",
"flowtype",
"jest"
],
"env": {
"browser": true,
"node": true
"node": true,
"jest/globals": true
},
"globals" : {
"__DEV__" : false,
Expand All @@ -26,6 +31,13 @@
"NODE_ENV" : false,
"DEBUG_PROD" : false
},
"settings": {
"import/resolver": {
"node": {
"paths": ["app"]
}
}
},
"rules": {
// ESLint Rules
"no-console": 2,
Expand All @@ -50,13 +62,11 @@
"babel/array-bracket-spacing": 2,
"babel/object-curly-spacing": [2, "always"],
"babel/object-shorthand": 2,

// Switch to error when requireForBlockBody works
"babel/arrow-parens": [0, "as-needed"/*, { "requireForBlockBody": true }*/],
"babel/no-await-in-loop": 2,
"babel/flow-object-type": 2,
"babel/func-params-comma-dangle": 2,
// "babel/no-invalid-this": 1,

// React Rules
"react/forbid-component-props": [0],
Expand Down Expand Up @@ -88,6 +98,7 @@
"static-methods",
"props",
"state",
"/.+Ref/",
"lifecycle",
"/^on.+$/",
"/^handle.+$/",
Expand Down Expand Up @@ -116,15 +127,13 @@
"react/jsx-indent": [2, 2],
"react/jsx-indent-props": [0, 2],
"react/jsx-key": [2],

"react/jsx-no-bind": [1],
"react/jsx-no-comment-textnodes": [2],
"react/jsx-no-duplicate-props": [2],
"react/jsx-no-literals": [0],
"react/jsx-no-target-blank": [2],
"react/jsx-no-undef": [2],
"react/jsx-pascal-case": [2],

"react/jsx-space-before-closing": [2],
"react/jsx-uses-react": [2],
"react/jsx-uses-vars": [2],
Expand All @@ -135,39 +144,7 @@
"jsx-a11y/img-redundant-alt": [2],
"jsx-a11y/aria-role": [2],
"jsx-a11y/no-access-key": [2],
"jsx-a11y/href-no-hash": "off",
"jsx-a11y/href-no-hash": "off"

"class-methods-use-this": "off",
"fp/no-arguments": "off",
"fp/no-class": "off",
"fp/no-delete": "off",
"fp/no-events": "off",
"fp/no-get-set": "off",
"fp/no-let": "off",
"fp/no-loops": "off",
"fp/no-mutating-assign": "off",
"fp/no-mutating-methods": "off",
"fp/no-mutation": "off",
"fp/no-nil": "off",
"fp/no-proxy": "off",
"fp/no-rest-parameters": "off",
"fp/no-this": "off",
"fp/no-throw": "off",
"fp/no-unused-expression": "off",
"fp/no-valueof-field": "off",
"import/no-extraneous-dependencies": "off",
"import/no-named-as-default": 0,
"no-var": "off",
"no-let": "off",
"no-plusplus": "off",
"no-use-before-define": "off",
"promise/avoid-new": "off",
},
"settings": {
"import/resolver": {
"node": {
"paths": ["app"]
}
}
},
}
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ branches:
only:
- master
- develop
- /^greenkeeper.*$/

addons:
apt:
Expand Down
26 changes: 13 additions & 13 deletions app/api/Butter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ export default new (class {
torrentAdapter: TorrentAdapter

constructor() {
this.pctAdapter = new PctTorrentProvider()
this.torrentAdapter = new TorrentAdapter()
this.pctAdapter = new PctTorrentProvider()
this.torrentAdapter = new TorrentAdapter()
this.metadataAdapter = new MetadataAdapter()
}

getMovies = (page: number = 1, filters: Object = {}) => (
this.pctAdapter.getMovies(page, filters)
.then(this.metadataAdapter.updateMoviesWatched)
.then(this.metadataAdapter.updateMoviesWatched)
)

getMovie = (itemId: string) => (
this.pctAdapter.getMovie(itemId)
.then(this.metadataAdapter.updateMovieWatched)
.then(this.metadataAdapter.updateMovieWatched)
)

getShows = (page: number = 1, filters: Object = {}) => (
Expand All @@ -33,15 +33,15 @@ export default new (class {

getShow = (itemId: string) => (
this.pctAdapter
.getShow(itemId)
.then(pctShow => (
this.metadataAdapter
.getSeasons(itemId, pctShow.seasons)
.then(seasons => ({
...pctShow,
seasons,
}))),
)
.getShow(itemId)
.then(pctShow => (
this.metadataAdapter
.getSeasons(itemId, pctShow.seasons)
.then(seasons => ({
...pctShow,
seasons,
}))),
)
)

searchEpisode = (...args) => (
Expand Down
3 changes: 2 additions & 1 deletion app/api/Database/Settings/SettingsConstants.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const DISCLAIMER = 'disclaimer'
export const DISCLAIMER = 'disclaimer'
export const STARTUP_SCREEN = 'startup_screen'
12 changes: 4 additions & 8 deletions app/api/Metadata/TmdbMetadataProvider/TmdbMetadataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,14 @@ export default class TmdbMetadataProvider implements MetadataProviderInterface {
}

formatImage = (image) => {
if (!image) {
return null
}

const replaceWidthPart = (uri: string, size: string) => this.imageUri + size + uri

return {
poster: {
full : replaceWidthPart(image, 'original'),
high : replaceWidthPart(image, 'w1280'),
medium: replaceWidthPart(image, 'w780'),
thumb : replaceWidthPart(image, 'w342'),
full : image ? replaceWidthPart(image, 'original') : null,
high : image ? replaceWidthPart(image, 'w1280') : null,
medium: image ? replaceWidthPart(image, 'w780') : null,
thumb : image ? replaceWidthPart(image, 'w342') : null,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/api/Player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class extends ReduxClazz implements PlayerProviderInterface {
this.play({ uri, item })
}

} else if (oldAction !== newAction) {
} else if (oldAction !== newAction && newAction) {
const { uri, item } = nextProps

this.handleActionChange(
Expand Down
11 changes: 8 additions & 3 deletions app/api/Player/PlayerActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ export function play(uri: string, item: ContentType) {
}

export const togglePlay = () => (dispatch, getState) => {
const playerStatus = PlayerSelectors.getStatus(getState())

if (playerStatus === PlayerConstants.STATUS_PLAYING) {
if (PlayerSelectors.getStatus(getState()) === PlayerConstants.STATUS_PLAYING) {
dispatch({
type: PlayerConstants.ACTION_PAUSE,
})
Expand Down Expand Up @@ -92,3 +90,10 @@ export function updateProvider(provider: string) {
}
}

export function toggleControls(show) {
return {
type : PlayerConstants.TOGGLE_CONTROLS,
payload: show,
}
}

2 changes: 2 additions & 0 deletions app/api/Player/PlayerConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ export const INITIAL_STATE = {
provider : PROVIDER_PLYR,
devices : [],
selectedDevice: null,
showControls : false,
}

export const UPDATE_PROVIDER = `${REDUCER_NAME}.player.type.update`
export const UPDATE_STATUS = `${REDUCER_NAME}.status.update`
export const FOUND_DEVICES = `${REDUCER_NAME}.devices.found`
export const SELECT_DEVICE = `${REDUCER_NAME}.devices.select`
export const TOGGLE_CONTROLS = `${REDUCER_NAME}.player.controls`
export const LOAD_ITEM = `${REDUCER_NAME}.load.item`
2 changes: 1 addition & 1 deletion app/api/Player/PlayerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as PlayerConstants from './PlayerConstants'
import * as TorrentConstants from '../Torrent/TorrentConstants'

export default (state = PlayerConstants.INITIAL_STATE, action) => {

switch (action.type) {
case PlayerConstants.ACTION_PLAY:
case PlayerConstants.ACTION_PAUSE:
Expand All @@ -20,6 +19,7 @@ export default (state = PlayerConstants.INITIAL_STATE, action) => {
return {
...state,
status: action.payload,
action: null,
}

case PlayerConstants.UPDATE_PROVIDER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ export default class extends ReduxClazz implements StreamingInterface {

isPlaying = () => this.status === PlayerConstants.STATUS_PLAYING

updateStatus = (nStatus) => {
log('updateStatus', nStatus)
const newStatus = nStatus && nStatus !== 'undefined' ? nStatus : PlayerConstants.STATUS_NONE
updateStatus = (newStatus) => {
log('updateStatus', newStatus)

if (newStatus !== this.status && newStatus !== 'undefined' ) {
if (this.states === PlayerConstants.STATUS_NONE && newStatus === PlayerConstants.STATUS_ENDED) {
return
}

if (newStatus !== this.status) {
log(`Update status to ${newStatus}`)
const { updateStatus } = this.props

Expand Down
1 change: 1 addition & 0 deletions app/api/Torrent/Torrent.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@flow
import { remote } from 'electron'
import WebTorrent from 'webtorrent'
import portfinder from 'portfinder'
Expand Down
12 changes: 11 additions & 1 deletion app/api/Torrents/TorrentsHelpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @flow
import hasOwnProperty from 'has-own-property'

export const formatShowToSearchQuery = (title, season, episode) => {
const searchTitle = title.toLowerCase()
.replace(' ', '.')
Expand Down Expand Up @@ -139,7 +141,7 @@ export const getBestTorrent = (torrentOne, torrentTwo) => {
return torrentTwo
}

export const getHighestQualtity = (torrents) => {
export const getHighestQuality = (torrents) => {
let bestQuality = null

Object.keys(torrents).forEach((quality) => {
Expand All @@ -156,3 +158,11 @@ export const getHighestQualtity = (torrents) => {

return null
}

export const itemHasTorrents = (item) => {
if (!hasOwnProperty(item, 'torrents')) {
return false
}

return !!getHighestQuality(item.torrents)
}
2 changes: 1 addition & 1 deletion app/components/Bookmarked/BookmarkedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import classes from './Bookmarked.scss'

export default ({ item, bookmarks, toggleBookmark, className, tooltip = { effect: 'solid', place: 'top' } }: Props) => {
const isBookmarked = bookmarks.indexOf(item.id) > -1

const bookmarkID = `${item.id}-bookmark-tooltip`

return (
<div
data-tip
Expand Down
2 changes: 1 addition & 1 deletion app/components/Bookmarked/BookmarkedContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export const mapStateToProps = state => ({
bookmarks: Selectors.getBookmarkes(state),
})

export default connect(mapStateToProps, { ...Actions })(BookmarkedComponent)
export default connect(mapStateToProps, Actions)(BookmarkedComponent)
10 changes: 4 additions & 6 deletions app/components/CardList/Card/Card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

.card {
border: 2px solid transparent;
max-width: $card-max-with;
min-width: $card-min-with;
width: 100%;
max-height: $card-max-height + 25px;
min-height: $card-min-height + 25px;
height: 100%;
width: $card-with;
min-width: $card-with;
max-width: $card-with;
height: $card-height + 25px;
margin: 3.5px;
overflow: hidden;
position: relative;
Expand Down
7 changes: 2 additions & 5 deletions app/components/CardList/Card/Cover/Cover.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
@import 'base/variables';

.cover {
max-width: $card-max-with;
width: $card-min-with;
max-height: $card-max-height;
min-height: $card-min-height;
height: 100%;
width: $card-with;
height: $card-height;
position: relative;
background-repeat: no-repeat;
background-size: cover;
Expand Down
8 changes: 3 additions & 5 deletions app/components/CardList/CardListComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import type { Props } from './CardListTypes'
import Card from './Card'
import classes from './CardList.scss'

export const CardList = ({ items, limit }: Props) => (
export default ({ items }: Props) => (
<div className={classes.container}>
{(limit ? items.filter((e, i) => i < limit) : items).map((item, index) => (
{Array.from(new Set(items)).map(item => (
<Card
key={`item-${index}`}
key={item.id}
item={item} />
))}
</div>
)

export default CardList
1 change: 0 additions & 1 deletion app/components/CardList/CardListTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
import type { ContentType } from 'api/Metadata/MetadataTypes'

export type Props = {
limit?: number,
items: Array<ContentType>,
}
Loading