From d43e9ecd68cdad3d8bde99a81f29e36674bc1b95 Mon Sep 17 00:00:00 2001 From: Daniel Shleifman Date: Wed, 16 Jun 2021 12:46:47 +0300 Subject: [PATCH] title format - removed year and resolution if exist --- .../TorrentCache/style.js | 2 +- .../DialogTorrentDetailsContent/index.jsx | 22 ++++++++++++++----- web/src/components/TorrentCard/index.jsx | 6 +++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js b/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js index 0c7584d..3887f5d 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js +++ b/web/src/components/DialogTorrentDetailsContent/TorrentCache/style.js @@ -62,5 +62,5 @@ export const SnakeWrapper = styled.div` export const PercentagePiece = styled.div` background: ${completeColor}; - height: ${({ percentage }) => (percentage)}%; + height: ${({ percentage }) => percentage}%; ` diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index 3311fcb..88aa75e 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -110,8 +110,11 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) { newNameStrings.push(title) } else if (torrentParsedName?.title) newNameStrings.push(torrentParsedName?.title) - // if (torrentParsedName?.year) newNameStrings.push(torrentParsedName?.year) - // if (torrentParsedName?.resolution) newNameStrings.push(torrentParsedName?.resolution) + // These 2 checks are needed to get year and resolution from torrent name if title does not have this info + if (torrentParsedName?.year && !title.includes(torrentParsedName?.year)) + newNameStrings.push(torrentParsedName?.year) + if (torrentParsedName?.resolution && !title.includes(torrentParsedName?.resolution)) + newNameStrings.push(torrentParsedName?.resolution) return newNameStrings.join(' ') } @@ -145,10 +148,17 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
{title && name !== title ? ( - <> - {ptt.parse(name).title} - {getParsedTitle()} - + getParsedTitle().length > 90 ? ( + <> + {ptt.parse(name).title} + {getParsedTitle()} + + ) : ( + <> + {getParsedTitle()} + {ptt.parse(name).title} + + ) ) : ( {getParsedTitle()} )} diff --git a/web/src/components/TorrentCard/index.jsx b/web/src/components/TorrentCard/index.jsx index 8106af8..40cc498 100644 --- a/web/src/components/TorrentCard/index.jsx +++ b/web/src/components/TorrentCard/index.jsx @@ -6,7 +6,7 @@ import { Close as CloseIcon, Delete as DeleteIcon, } from '@material-ui/icons' -import { getPeerString, humanizeSize, shortenText } from 'utils/Utils' +import { getPeerString, humanizeSize } from 'utils/Utils' import { torrentsHost } from 'utils/Hosts' import { NoImageIcon } from 'icons' import DialogTorrentDetailsContent from 'components/DialogTorrentDetailsContent' @@ -42,7 +42,9 @@ const Torrent = ({ torrent }) => { 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') @@ -90,7 +92,7 @@ const Torrent = ({ torrent }) => {
{t('Name')}
-
{shortenText(parsedTitle, 255)}
+
{parsedTitle}