- {props.data.episode} |
- {props.data.title} |
-
+ |
+
+ {props.data.episode}
+ |
+ {props.data.title} |
+
{props.data.torrents && props.data.torrents.map(function(torrent, index) {
let key = `${props.data.season}-${props.data.episode}-${torrent.source}-${torrent.quality}`;
@@ -178,13 +202,95 @@ class Torrent extends React.Component {
}
}
+class TrackHeader extends React.Component {
+ constructor(props) {
+ super(props);
+ this.handleClick = this.handleClick.bind(this);
+ }
+ handleClick(e, url) {
+ e.preventDefault();
+ let wishlisted = (this.props.data.tracked_season !== null && this.props.data.tracked_episode !== null);
+ if (wishlisted) {
+ this.props.deleteFromWishlist(this.props.data.imdb_id);
+ } else {
+ this.props.addToWishlist(this.props.data.imdb_id);
+ }
+ }
+ render() {
+ let wishlisted = (this.props.data.tracked_season !== null && this.props.data.tracked_episode !== null);
+ if (wishlisted) {
+ let msg;
+ if (this.props.data.tracked_season !== 0 && this.props.data.tracked_episode !== 0) {
+ msg = (
+
+ Show tracked from season {this.props.data.tracked_season} episode {this.props.data.tracked_episode}
+
+ );
+ } else {
+ msg = (
+
+ Whole show tracked
+
+ );
+ }
+ return (
+
+ - Tracking active
+ {msg}
+
+ -
+ this.handleClick(e)}>
+ Untrack the show
+
+
+
+ );
+ } else {
+ return (
+
+ - Tracking inactive
+ -
+ this.handleClick(e)}>
+ Track the whole show
+
+
+
+ );
+ }
+ }
+}
+
+class TrackButton extends React.Component {
+ constructor(props) {
+ super(props);
+ this.handleClick = this.handleClick.bind(this);
+ }
+ handleClick(e, url) {
+ e.preventDefault();
+ this.props.addToWishlist(this.props.data.show_imdb_id, this.props.data.season, this.props.data.episode);
+ }
+ render() {
+ const tooltipId = `tooltip-${this.props.data.season}-${this.props.data.episode}`;
+ const tooltip = (
+ Track show from here
+ );
+ return (
+
+ this.handleClick(e)}>
+
+
+
+ );
+ }
+}
+
function DownloadButton(props) {
if (props.data.polochon_url === "") {
return null
}
return (
-
+
Download
diff --git a/src/public/js/reducers/shows.js b/src/public/js/reducers/shows.js
index bc32e30..5d940fc 100644
--- a/src/public/js/reducers/shows.js
+++ b/src/public/js/reducers/shows.js
@@ -47,7 +47,8 @@ export default function showStore(state = defaultState, action) {
})
case 'SHOW_UPDATE_STORE_WISHLIST':
return Object.assign({}, state, {
- shows: updateStoreWishlist(state.shows.slice(), action.payload),
+ shows: updateShowsStoreWishlist(state.shows.slice(), action.payload),
+ show: updateShowStoreWishlist(Object.assign({}, state.show), action.payload),
})
case 'SELECT_SHOW':
// Don't select the show if we're fetching another show's details
@@ -107,7 +108,12 @@ function sortEpisodes(show) {
return show;
}
-function updateStoreWishlist(shows, payload) {
+// Update the store containing all the shows
+function updateShowsStoreWishlist(shows, payload) {
+ if (shows.length === 0) {
+ return shows;
+ }
+
let index = shows.map((el) => el.imdb_id).indexOf(payload.imdbId);
let season = payload.season;
let episode = payload.episode;
@@ -123,3 +129,23 @@ function updateStoreWishlist(shows, payload) {
shows[index].tracked_episode = episode;
return shows
}
+
+// Update the store containing the current detailed show
+function updateShowStoreWishlist(show, payload) {
+ if (show.seasons.length === 0) {
+ return show;
+ }
+ let season = payload.season;
+ let episode = payload.episode;
+ if (payload.wishlisted) {
+ if (season === null) {
+ season = 0;
+ }
+ if (episode === null) {
+ episode = 0;
+ }
+ }
+ show.tracked_season = season;
+ show.tracked_episode = episode;
+ return show
+}
|