import React from 'react' import DownloadButton from '../buttons/download' import TorrentsButton from './torrents' import ActionsButton from './actions' import ListPosters from '../list/posters' import ListDetails from '../list/details' import Loader from '../loader/loader' function MovieButtons(props) { const imdb_link = `http://www.imdb.com/title/${props.movie.imdb_id}`; const hasMovie = (props.movie.polochon_url !== ""); return (
{props.movie.torrents && } IMDB
); } export default class MovieList extends React.Component { handleParams(props = this.props) { // Check if the URL to fetch is in the props if (props.moviesUrl) { this.props.fetchMovies(props.moviesUrl); return } // Check for URL parameters if (!props.params) { return } // Search param if (props.params.search && props.params.search !== "") { props.searchMovies({ key: props.params.search }); return } } componentWillMount() { this.handleParams(); } componentWillUpdate(nextProps, nextState) { // No params if (!nextProps.params) { return } // Search field changed if (this.props.params.search && (this.props.params.search !== nextProps.params.search) && (nextProps.params.search !== "")) { this.handleParams(nextProps); return } } render() { const movies = this.props.movieStore.movies; const selectedMovieId = this.props.movieStore.selectedImdbId; let index = movies.map((el) => el.imdb_id).indexOf(selectedMovieId); if (index === -1) { index = 0; } const selectedMovie = movies[index]; // Loading if (this.props.movieStore.loading) { return (); } return (
{selectedMovie && }
); } }