Add a pretty name to the listed torrents
This commit is contained in:
parent
f8db5e1211
commit
3d7b663f97
@ -2,7 +2,7 @@ import React, { useState } from "react";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
import { prettySize } from "../../utils";
|
import { prettySize, prettyEpisodeName } from "../../utils";
|
||||||
import { addTorrent, removeTorrent } from "../../actions/torrents";
|
import { addTorrent, removeTorrent } from "../../actions/torrents";
|
||||||
|
|
||||||
export const TorrentList = () => {
|
export const TorrentList = () => {
|
||||||
@ -81,6 +81,23 @@ const Torrent = ({ torrent }) => {
|
|||||||
percentDone = Number(percentDone).toFixed(1) + "%";
|
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
|
// Pretty sizes
|
||||||
const downloadedSize = prettySize(torrent.status.downloaded_size);
|
const downloadedSize = prettySize(torrent.status.downloaded_size);
|
||||||
const totalSize = prettySize(torrent.status.total_size);
|
const totalSize = prettySize(torrent.status.total_size);
|
||||||
@ -88,7 +105,7 @@ const Torrent = ({ torrent }) => {
|
|||||||
return (
|
return (
|
||||||
<div className="card w-100 mb-3">
|
<div className="card w-100 mb-3">
|
||||||
<h5 className="card-header">
|
<h5 className="card-header">
|
||||||
<span className="text text-break">{torrent.status.name}</span>
|
<span className="text text-break">{torrentTitle(torrent)}</span>
|
||||||
<span
|
<span
|
||||||
className="fa fa-trash clickable pull-right"
|
className="fa fa-trash clickable pull-right"
|
||||||
onClick={() => dispatch(removeTorrent(torrent.status.id))}
|
onClick={() => dispatch(removeTorrent(torrent.status.id))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user