From db521fff7655f06c6658839ce5679fa7bfa40eda Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 01:37:56 +0100 Subject: [PATCH 01/11] CSS text-ellipsis of item summary --- app/components/item/Item.js | 11 +---------- app/styles/components/Item.scss | 12 ++++++++++++ app/styles/variables.scss | 4 ---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index 6c33257b..252d35c0 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -103,8 +103,6 @@ export default class Item extends Component { checkCastingDevicesInterval: number; - SUMMARY_CHAR_LIMIT = 300; - defaultTorrent: torrentSelectionType = { default: { quality: undefined, @@ -919,14 +917,7 @@ export default class Item extends Component { {item.genres &&
{item.genres.join(', ')}
} - {/* HACK: Prefer a CSS solution to this, using text-overflow: ellipse */} -
- {item.summary - ? item.summary.length > this.SUMMARY_CHAR_LIMIT - ? `${item.summary.slice(0, this.SUMMARY_CHAR_LIMIT)}...` - : item.summary - : ''} -
+
{item.summary}
{item.rating && typeof item.rating === 'number' && ( diff --git a/app/styles/components/Item.scss b/app/styles/components/Item.scss index 640a521c..088a59b4 100644 --- a/app/styles/components/Item.scss +++ b/app/styles/components/Item.scss @@ -48,6 +48,18 @@ } } + //cf. https://codepen.io/martinwolf/pen/qlFdp + .item__summary { + display: block; /* Fallback for non-webkit */ + display: -webkit-box; + margin: 0 auto; + line-height: 2rem; + -webkit-line-clamp: 3; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; + } + > .row > .plyr { position: absolute; left: 0; diff --git a/app/styles/variables.scss b/app/styles/variables.scss index 7833db2c..a3ba117a 100644 --- a/app/styles/variables.scss +++ b/app/styles/variables.scss @@ -83,10 +83,6 @@ $headings-font-weight: 400; margin: 20px 0; } -#summary { - line-height: 2rem; -} - ::selection { background: black; color: white; From 249d2cde5509d8c583b37427a410a1ba2d7855d3 Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 01:39:50 +0100 Subject: [PATCH 02/11] No need to wrap event props --- app/components/item/Item.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index 252d35c0..28d0fef0 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -492,7 +492,7 @@ export default class Item extends Component { return []; } - stopPlayback() { + stopPlayback = () => { const { torrentInProgress, playbackInProgress, currentPlayer } = this.state; if (!torrentInProgress && !playbackInProgress) { return; @@ -509,7 +509,7 @@ export default class Item extends Component { this.player.destroy(); this.torrent.destroy(); this.setState({ torrentInProgress: false }); - } + }; selectShow = ( type: string, @@ -621,7 +621,7 @@ export default class Item extends Component { return captions; } - closeVideo() { + closeVideo = () => { const { playbackInProgress } = this.state; if (!playbackInProgress) { return; @@ -631,7 +631,7 @@ export default class Item extends Component { this.setState({ currentPlayer: 'default' }); - } + }; toggleActive() { this.setState(prevState => ({ @@ -807,7 +807,7 @@ export default class Item extends Component { role="presentation" className="pct-btn pct-btn-tran pct-btn-outline pct-btn-round" data-e2e="item-button-back" - onClick={() => this.stopPlayback()} + onClick={this.stopPlayback} > Back @@ -815,11 +815,6 @@ export default class Item extends Component { { data-e2e="close-player" role="presentation" id="close-button" - onClick={() => this.closeVideo()} + onClick={this.closeVideo} > From 17c82b9e48c051039b159356da23b85fd9d91a72 Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 10:09:51 +0100 Subject: [PATCH 03/11] Fix summary test --- test/e2e/HomePage.e2e.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/HomePage.e2e.js b/test/e2e/HomePage.e2e.js index 6820b34c..41f3d7ad 100644 --- a/test/e2e/HomePage.e2e.js +++ b/test/e2e/HomePage.e2e.js @@ -56,7 +56,7 @@ test('it should navigate to item on CardList click', async t => { .contains('#/item/shows/') .expect(Selector('#title').visible) .ok() - .expect(Selector('#summary').visible) + .expect(Selector('.item__summary').visible) .ok(); }); From 76cffaea861655e318c952f6457e47b729538edf Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 10:37:09 +0100 Subject: [PATCH 04/11] CSS solution for torrent health --- app/components/item/Item.js | 19 +++++-------------- app/styles/components/Movie.scss | 23 ++++++++++++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index 28d0fef0..0e810738 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -780,18 +780,10 @@ export default class Item extends Component { const { activeMode } = this.props; - const statusColorStyle = { - backgroundColor: (() => { - switch (idealTorrent && idealTorrent.health) { - case 'healthy': - return 'green'; - case 'decent': - return 'yellow'; - default: - return 'red'; - } - })() - }; + const torrentHealthClassName = classNames([ + 'torrent__health', + { [`torrent__health--${idealTorrent.health}`]: idealTorrent.health } + ]); const itemBackgroundUrl = { backgroundImage: `url(${item.images.fanart.full})` @@ -938,8 +930,7 @@ export default class Item extends Component {
Date: Sun, 21 Apr 2019 10:47:04 +0100 Subject: [PATCH 05/11] Use uncontrolled tooltip --- app/components/item/Item.js | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index 0e810738..ef12866a 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -4,14 +4,14 @@ */ import React, { Component } from 'react'; import { - Tooltip, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, Container, Row, - Col + Col, + UncontrolledTooltip } from 'reactstrap'; import { Link } from 'react-router-dom'; import classNames from 'classnames'; @@ -75,7 +75,6 @@ type State = { fetchingTorrents: boolean, dropdownOpen: boolean, idealTorrent: torrentType, - magnetPopoverOpen: boolean, torrent: torrentSelectionType, servingUrl: string, similarLoading: boolean, @@ -165,7 +164,6 @@ export default class Item extends Component { episode: {}, castingDevices: [], currentPlayer: 'default', - magnetPopoverOpen: false, playbackInProgress: false, fetchingTorrents: false, idealTorrent: this.defaultTorrent, @@ -639,12 +637,6 @@ export default class Item extends Component { })); } - toggleStateProperty(property: string) { - this.setState(prevState => ({ - [property]: !prevState[property] - })); - } - async startPlayback( magnet?: string, activeMode?: string, @@ -772,8 +764,6 @@ export default class Item extends Component { playbackInProgress, favorites, watchList, - magnetPopoverOpen, - trailerPopoverOpen, castingDevices, captions } = this.state; @@ -932,17 +922,15 @@ export default class Item extends Component { data-e2e="item-magnet-torrent-health-popover" className={torrentHealthClassName} /> - this.toggleStateProperty('magnetPopoverOpen')} > {idealTorrent && idealTorrent.seeders ? idealTorrent.seeders : 0}{' '} Seeders - + {process.env.NODE_ENV === 'test' && @@ -956,16 +944,12 @@ export default class Item extends Component { onClick={() => this.setPlayer('youtube')} role="presentation" /> - - this.toggleStateProperty('trailerPopoverOpen') - } > Trailer - + )} From 60b89fd36350c0fe8175ee79cfc0ceb1e029501c Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 10:49:52 +0100 Subject: [PATCH 06/11] Use uncontrolled dropdown --- app/components/item/Item.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index ef12866a..e21c1334 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -4,7 +4,7 @@ */ import React, { Component } from 'react'; import { - Dropdown, + UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem, @@ -73,7 +73,6 @@ type State = { currentPlayer: playerType, playbackInProgress: boolean, fetchingTorrents: boolean, - dropdownOpen: boolean, idealTorrent: torrentType, torrent: torrentSelectionType, servingUrl: string, @@ -155,7 +154,6 @@ export default class Item extends Component { } }, servingUrl: undefined, - dropdownOpen: false, isFinished: false, selectedSeason: 1, selectedEpisode: 1, @@ -214,12 +212,6 @@ export default class Item extends Component { this.setState({ currentPlayer: player }); } - toggle() { - this.setState(prevState => ({ - dropdownOpen: !prevState.dropdownOpen - })); - } - async componentDidMount() { const { itemId } = this.props; window.scrollTo(0, 0); @@ -234,7 +226,6 @@ export default class Item extends Component { this.setState({ ...this.initialState, - dropdownOpen: false, currentPlayer: 'default', favorites: await this.butter.favorites('get'), watchList: await this.butter.watchList('get') @@ -752,7 +743,6 @@ export default class Item extends Component { servingUrl, torrentInProgress, fetchingTorrents, - dropdownOpen, currentPlayer, seasons, selectedSeason, @@ -961,11 +951,7 @@ export default class Item extends Component { - this.toggle()} - > + {currentPlayer || 'default'} @@ -998,7 +984,7 @@ export default class Item extends Component { ))} - + {process.env.FLAG_MANUAL_TORRENT_SELECTION === 'true' && ( From b8932400e0f13f1f73ac922f59c14f1ad8e08c76 Mon Sep 17 00:00:00 2001 From: Pedro Abreu Date: Sun, 21 Apr 2019 11:17:04 +0100 Subject: [PATCH 07/11] Read playback information from state directly --- app/components/item/Item.js | 66 +++++++++++++------------------------ 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/app/components/item/Item.js b/app/components/item/Item.js index e21c1334..8de4e7c5 100644 --- a/app/components/item/Item.js +++ b/app/components/item/Item.js @@ -628,19 +628,24 @@ export default class Item extends Component { })); } - async startPlayback( - magnet?: string, - activeMode?: string, - currentPlayer: playerType - ) { + startPlayback = async ({ + target: { name: playbackQuality } + }: Event) => { const { + currentPlayer, torrentInProgress, selectedEpisode, selectedSeason, item, - captions + captions, + torrent, + idealTorrent } = this.state; + const { magnet, method: activeMode } = playbackQuality + ? torrent[playbackQuality] + : idealTorrent; + if (torrentInProgress) { this.stopPlayback(); } @@ -672,7 +677,7 @@ export default class Item extends Component { servingUrl: string, file: { name: string }, files: string, - torrent: string + torrentHash: string ) => { console.log(`Serving torrent at: ${servingUrl}`); @@ -727,13 +732,13 @@ export default class Item extends Component { servingUrl }); - return torrent; + return torrentHash; }, downloaded => { console.log('DOWNLOADING', downloaded); } ); - } + }; render() { const { @@ -820,26 +825,14 @@ export default class Item extends Component {
- this.startPlayback( - idealTorrent.magnet, - idealTorrent.method, - currentPlayer - ) - } + onClick={this.startPlayback} > {idealTorrent.magnet && ( - this.startPlayback( - idealTorrent.magnet, - idealTorrent.method, - currentPlayer - ) - } + onClick={this.startPlayback} /> )}
@@ -991,26 +984,16 @@ export default class Item extends Component {