From 086d70b0cf242e997c662f7fc28641a8b23a16de Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Wed, 16 Jun 2021 05:17:44 +0300 Subject: [PATCH] use long titles with year and res --- .../DialogTorrentDetailsContent/index.jsx | 2 +- web/src/components/TorrentCard/index.jsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index 158ac23..3311fcb 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -1,5 +1,5 @@ import { NoImageIcon } from 'icons' -import { humanizeSize, shortenText } from 'utils/Utils' +import { humanizeSize } from 'utils/Utils' import { useEffect, useState } from 'react' import { Button, ButtonGroup } from '@material-ui/core' import ptt from 'parse-torrent-title' diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index dc88def..8106af8 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -40,7 +40,19 @@ const 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 + const getParsedTitle = () => { + const parse = key => ptt.parse(title || '')?.[key] || ptt.parse(name || '')?.[key] + const titleStrings = [] + let parsedTitle = parse('title') + const parsedYear = parse('year') + const parsedResolution = parse('resolution') + if (parsedTitle) titleStrings.push(parsedTitle) + if (parsedYear) titleStrings.push(`(${parsedYear})`) + if (parsedResolution) titleStrings.push(`[${parsedResolution}]`) + parsedTitle = titleStrings.join(' ') + return { parsedTitle } + } + const { parsedTitle } = getParsedTitle() const [isEditDialogOpen, setIsEditDialogOpen] = useState(false) const handleClickOpenEditDialog = () => setIsEditDialogOpen(true) @@ -78,7 +90,7 @@ const Torrent = ({ torrent }) => {
{t('Name')}
-
{shortenText(parsedTitle, 100)}
+
{shortenText(parsedTitle, 255)}