From 8d242b8cf0504c0e6c6de32155db718e5b280da5 Mon Sep 17 00:00:00 2001 From: Daniel Shleifman Date: Wed, 2 Jun 2021 22:46:17 +0300 Subject: [PATCH] refactor --- web/src/components/TorrentCard/index.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index 022216c..d8c94f1 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -9,6 +9,7 @@ import Dialog from '@material-ui/core/Dialog' import Slide from '@material-ui/core/Slide' import { Button, DialogActions, DialogTitle, useMediaQuery, useTheme } from '@material-ui/core' import axios from 'axios' +import ptt from 'parse-torrent-title' import { StyledButton, TorrentCard, TorrentCardButtons, TorrentCardDescription, TorrentCardPoster } from './style' @@ -31,6 +32,8 @@ export default function Torrent({ torrent }) { const dropTorrent = () => axios.post(torrentsHost(), { action: 'drop', hash }) const deleteTorrent = () => axios.post(torrentsHost(), { action: 'rem', hash }) + const parsedTitle = (title || name) && ptt.parse(title || name).title + return ( <> @@ -58,7 +61,7 @@ export default function Torrent({ torrent }) {
Name
-
{shortenText(title || name, 100)}
+
{shortenText(parsedTitle, 100)}