Skip to content

Commit

Permalink
v1.4.0 (#574)
Browse files Browse the repository at this point in the history
* Tidy up home component (#571)

* v1.3.3 (#570)

* bump to v1.3.3

* Sticky navbar (#569)

* collapse toggler on click

* sticky navbar

* remove custom scrollbar styling to fix padding issues with container

* Remove dead code

* onChange is a class method

* initInfinitePagination as arrow to avoid explicit binding

* component is already aware of redux, no need to bindActionCreators

* Only import what's needed

* fix subtitles (#572)

fix subtitles, add multi-lang subtitle support

* semver bump to 1.3.4
  • Loading branch information
amilajack authored Apr 21, 2019
1 parent 3017b63 commit bddefe3
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 123 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ FLAG_NATIVE_PLAYBACK_FILTERING=false
# *.mock.js.

API_USE_MOCK_DATA=false

# Default Torrent Language
#
# This sets the language that torrents will be loaded for

DEFAULT_TORRENT_LANG=en
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply. -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
- [ ] Your pull request targets the `master` branch.
- [ ] Your pull request targets the `next` branch.
- [ ] Branch starts with either `fix/` or `feature/` (e.g. `fix/signin-issue`)
- [ ] All new and existing tests pass.

Expand Down
43 changes: 43 additions & 0 deletions app/api/Subtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,46 @@ export default class SubtitleServer {
});
}
}

export const languages = [
// 'sq',
'ar',
// 'bn',
// 'pb',
// 'bg',
'zh',
// 'hr',
// 'cs',
// 'da',
// 'nl',
'en',
// 'et',
// 'fa',
// 'fi',
// 'fr',
// 'de',
// 'el',
// 'he',
// 'hu',
// 'id',
// 'it',
// 'ja',
// 'ko',
// 'lt',
// 'mk',
// 'ms',
// 'no',
// 'pl',
// 'pt',
// 'ro',
'ru',
// 'sr',
// 'sl',
'es'
// 'sv',
// 'th',
// 'tr',
// 'ur',
// 'uk',
// 'vi'
];
78 changes: 30 additions & 48 deletions app/components/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@ export type itemType = {
};

type Props = {
actions: {
setActiveMode: (
mode: string,
activeModeOptions?: activeModeOptionsType
) => void,
paginate: (
activeMode: string,
activeModeOptions?: activeModeOptionsType
) => void,
clearAllItems: () => void,
setLoading: (isLoading: boolean) => void
},
setActiveMode: (
mode: string,
activeModeOptions?: activeModeOptionsType
) => void,
paginate: (
activeMode: string,
activeModeOptions?: activeModeOptionsType
) => void,
clearAllItems: () => void,
setLoading: (isLoading: boolean) => void,
activeMode: string,
activeModeOptions: activeModeOptionsType,
modes: {
Expand Down Expand Up @@ -69,21 +67,10 @@ export default class Home extends Component<Props, State> {

butter: Butter;

didMount: boolean;

// onChange: () => void;

constructor(props: Props) {
super(props);
this.butter = new Butter();

this.onChange = async (isVisible: boolean) => {
const { isLoading, activeMode, activeModeOptions } = this.props;
if (isVisible && !isLoading) {
await this.paginate(activeMode, activeModeOptions);
}
};

// Temporary hack to preserve scroll position
if (!global.pct) {
global.pct = {
Expand All @@ -107,9 +94,9 @@ export default class Home extends Component<Props, State> {
queryType: string,
activeModeOptions: activeModeOptionsType = {}
) {
const { actions, modes } = this.props;
const { modes, paginate, setLoading } = this.props;

actions.setLoading(true);
setLoading(true);

// HACK: This is a temporary solution.
// Waiting on: https://github.com/yannickcr/eslint-plugin-react/issues/818
Expand All @@ -130,16 +117,16 @@ export default class Home extends Component<Props, State> {
}
})();

actions.paginate(items);
actions.setLoading(false);
paginate(items);
setLoading(false);

return items;
}

/**
* If bottom of component is 2000px from viewport, query
*/
initInfinitePagination() {
initInfinitePagination = () => {
const {
infinitePagination,
activeMode,
Expand All @@ -155,18 +142,12 @@ export default class Home extends Component<Props, State> {
this.paginate(activeMode, activeModeOptions);
}
}
}

setUserMeta(type: 'favorites' | 'watchList', item) {
this.setState({
[type]: this.butter[type]('set', item)
});
}
};

async componentDidMount() {
const { activeMode } = this.props;
this.didMount = true;
document.addEventListener('scroll', this.initInfinitePagination.bind(this));

document.addEventListener('scroll', this.initInfinitePagination);
window.scrollTo(0, global.pct[`${activeMode}ScrollTop`]);

const [favorites, watchList, recentlyWatched] = await Promise.all([
Expand All @@ -182,10 +163,8 @@ export default class Home extends Component<Props, State> {
});
}

componentWillMount() {}

componentWillReceiveProps(nextProps: Props) {
const { activeMode, activeModeOptions, actions } = this.props;
const { activeMode, activeModeOptions, clearAllItems } = this.props;
global.pct[`${activeMode}ScrollTop`] = document.body.scrollTop;

if (activeMode !== nextProps.activeMode) {
Expand All @@ -197,7 +176,7 @@ export default class Home extends Component<Props, State> {
JSON.stringify(activeModeOptions)
) {
if (nextProps.activeMode === 'search') {
actions.clearAllItems();
clearAllItems();
}

this.paginate(nextProps.activeMode, nextProps.activeModeOptions);
Expand All @@ -221,15 +200,18 @@ export default class Home extends Component<Props, State> {

global.pct[`${activeMode}ScrollTop`] = document.body.scrollTop;

this.didMount = false;
document.removeEventListener(
'scroll',
this.initInfinitePagination.bind(this)
);
document.removeEventListener('scroll', this.initInfinitePagination);
}

onChange = async (isVisible: boolean) => {
const { isLoading, activeMode, activeModeOptions } = this.props;
if (isVisible && !isLoading) {
await this.paginate(activeMode, activeModeOptions);
}
};

render() {
const { activeMode, actions, items, isLoading } = this.props;
const { activeMode, items, isLoading, setActiveMode } = this.props;
const { favorites, watchList, recentlyWatched } = this.state;

const home = (
Expand All @@ -254,7 +236,7 @@ export default class Home extends Component<Props, State> {

return (
<Row>
<Header activeMode={activeMode} setActiveMode={actions.setActiveMode} />
<Header activeMode={activeMode} setActiveMode={setActiveMode} />
<Col sm="12">
{activeMode === 'home' ? (
home
Expand Down
58 changes: 4 additions & 54 deletions app/components/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import ChromecastPlayerProvider from '../../api/players/ChromecastPlayerProvider
import { getIdealTorrent } from '../../api/torrents/BaseTorrentProvider';
import Butter from '../../api/Butter';
import Torrent from '../../api/Torrent';
import SubtitleServer from '../../api/Subtitle';
import SubtitleServer, { languages as langs } from '../../api/Subtitle';
import Player from '../../api/Player';
import type {
contentType,
Expand Down Expand Up @@ -555,57 +555,12 @@ export default class Item extends Component<Props, State> {
async getCaptions(item: contentType): Promise<captionsType> {
const captions: Array<captionsType> = await yifysubtitles(item.ids.imdbId, {
path: os.tmpdir(),
langs: ['en', 'fr']
// langs: [
// 'sq',
// 'ar',
// 'bn',
// 'pb',
// 'bg',
// 'zh',
// 'hr',
// 'cs',
// 'da',
// 'nl',
// 'en',
// 'et',
// 'fa',
// 'fi',
// 'fr',
// 'de',
// 'el',
// 'he',
// 'hu',
// 'id',
// 'it',
// 'ja',
// 'ko',
// 'lt',
// 'mk',
// 'ms',
// 'no',
// 'pl',
// 'pt',
// 'ro',
// 'ru',
// 'sr',
// 'sl',
// 'es',
// 'sv',
// 'th',
// 'tr',
// 'ur',
// 'uk',
// 'vi'
// ]
langs
})
.then(res =>
res.map(subtitle => ({
// Set en
// default: (
// subtitle.langShort === process.env.DEFAULT_TORRENT_LANG || subtitle.langShort === process.env.DEFAULT_TORRENT_LANG === 'en'
// ),
default: subtitle.langShort === 'en',
// Set the default language for subtitles
default: subtitle.langShort === process.env.DEFAULT_TORRENT_LANG,
kind: 'captions',
label: subtitle.langShort,
srclang: subtitle.langShort,
Expand Down Expand Up @@ -817,11 +772,6 @@ export default class Item extends Component<Props, State> {
<Row>
<Plyr
captions={captions}
// captions={[{
// kind: "captions",
// label: "English captions",
// src: 'http://localhost:4000/Deadpool.2.Super.Duper.Cut.2018.HDRip.XviD.AC3-EVO.vtt'
// }]}
type="video"
url={playbackInProgress ? servingUrl || item.trailer : undefined}
poster={(item && item.images && item.images.fanart.full) || ''}
Expand Down
15 changes: 12 additions & 3 deletions app/containers/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* @flow
* @TODO: Use waitForImages plugin to load background images and fade in on load
*/
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as HomeActions from '../actions/homePageActions';
import {
clearAllItems,
paginate,
setActiveMode,
setLoading
} from '../actions/homePageActions';
import Home from '../components/home/Home';

function mapStateToProps(state) {
Expand All @@ -21,7 +25,12 @@ function mapStateToProps(state) {

function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators(HomeActions, dispatch)
clearAllItems: () => dispatch(clearAllItems()),
paginate: (activeMode, activeModeOptions) =>
dispatch(paginate(activeMode, activeModeOptions)),
setActiveMode: (mode, activeModeOptions) =>
dispatch(setActiveMode(mode, activeModeOptions)),
setLoading: isLoading => dispatch(setLoading(isLoading))
};
}

Expand Down
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Root from './containers/Root';
import { history, configureStore } from './store/configureStore';
import './app.global.scss';

if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'production' && process.env.E2E_BUILD !== 'true') {
Sentry.init({
dsn: 'https://[email protected]/1277263'
});
Expand Down
2 changes: 1 addition & 1 deletion app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import log from 'electron-log';
import * as Sentry from '@sentry/electron/dist/main';
import MenuBuilder from './menu';

if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'production' && process.env.E2E_BUILD !== 'true') {
Sentry.init({
dsn: 'https://[email protected]/1277263'
});
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "PopcornTime",
"description": "An experimental PopcornTime client",
"homepage": "https://github.com/amilajack/popcorn-time-desktop",
"version": "1.3.3",
"version": "1.4.0",
"main": "./main.prod.js",
"author": {
"name": "Amila Welihinda <[email protected]>",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "popcorn-time-desktop",
"version": "1.3.3",
"version": "1.4.0",
"description": "An experimental Popcorn Time client",
"scripts": {
"bench-api": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 jest test/**/*.benchmark.js",
Expand Down Expand Up @@ -240,7 +240,7 @@
},
"dependencies": {
"@amilajack/react-plyr": "^2.1.2",
"@amilajack/yifysubtitles": "^2.1.2",
"@amilajack/yifysubtitles": "^2.1.4",
"@sentry/electron": "^0.17.1",
"axios": "^0.18.0",
"bootstrap": "4.3.1",
Expand Down
Loading

0 comments on commit bddefe3

Please sign in to comment.