From 23aa53bde7768df885b6fa7be27f035a12fc56ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Sat, 11 Apr 2020 18:10:56 +0200 Subject: [PATCH] Add a pretty name to the listed torrents --- frontend/js/components/torrents/list.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/frontend/js/components/torrents/list.js b/frontend/js/components/torrents/list.js index 39cdb50..8866198 100644 --- a/frontend/js/components/torrents/list.js +++ b/frontend/js/components/torrents/list.js @@ -2,7 +2,7 @@ import React, { useState } from "react"; import PropTypes from "prop-types"; import { useDispatch, useSelector } from "react-redux"; -import { prettySize } from "../../utils"; +import { prettySize, prettyEpisodeName } from "../../utils"; import { addTorrent, removeTorrent } from "../../actions/torrents"; export const TorrentList = () => { @@ -81,6 +81,23 @@ const Torrent = ({ torrent }) => { percentDone = Number(percentDone).toFixed(1) + "%"; } + const torrentTitle = (torrent) => { + switch (torrent.type) { + case "movie": + return torrent.video ? torrent.video.title : torrent.status.name; + case "episode": + return torrent.video + ? prettyEpisodeName( + torrent.video.show_title, + torrent.video.season, + torrent.video.episode + ) + : torrent.status.name; + default: + return torrent.status.name; + } + }; + // Pretty sizes const downloadedSize = prettySize(torrent.status.downloaded_size); const totalSize = prettySize(torrent.status.total_size); @@ -88,7 +105,7 @@ const Torrent = ({ torrent }) => { return (
- {torrent.status.name} + {torrentTitle(torrent)} dispatch(removeTorrent(torrent.status.id))}