title format - removed year and resolution if exist

This commit is contained in:
Daniel Shleifman
2021-06-16 12:46:47 +03:00
parent aaa5596751
commit d43e9ecd68
3 changed files with 21 additions and 9 deletions

View File

@@ -62,5 +62,5 @@ export const SnakeWrapper = styled.div`
export const PercentagePiece = styled.div` export const PercentagePiece = styled.div`
background: ${completeColor}; background: ${completeColor};
height: ${({ percentage }) => (percentage)}%; height: ${({ percentage }) => percentage}%;
` `

View File

@@ -110,8 +110,11 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
newNameStrings.push(title) newNameStrings.push(title)
} else if (torrentParsedName?.title) newNameStrings.push(torrentParsedName?.title) } else if (torrentParsedName?.title) newNameStrings.push(torrentParsedName?.title)
// if (torrentParsedName?.year) newNameStrings.push(torrentParsedName?.year) // These 2 checks are needed to get year and resolution from torrent name if title does not have this info
// if (torrentParsedName?.resolution) newNameStrings.push(torrentParsedName?.resolution) 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(' ') return newNameStrings.join(' ')
} }
@@ -145,10 +148,17 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
<div> <div>
{title && name !== title ? ( {title && name !== title ? (
<> getParsedTitle().length > 90 ? (
<SectionTitle>{ptt.parse(name).title}</SectionTitle> <>
<SectionSubName mb={20}>{getParsedTitle()}</SectionSubName> <SectionTitle>{ptt.parse(name).title}</SectionTitle>
</> <SectionSubName mb={20}>{getParsedTitle()}</SectionSubName>
</>
) : (
<>
<SectionTitle>{getParsedTitle()}</SectionTitle>
<SectionSubName mb={20}>{ptt.parse(name).title}</SectionSubName>
</>
)
) : ( ) : (
<SectionTitle mb={20}>{getParsedTitle()}</SectionTitle> <SectionTitle mb={20}>{getParsedTitle()}</SectionTitle>
)} )}

View File

@@ -6,7 +6,7 @@ import {
Close as CloseIcon, Close as CloseIcon,
Delete as DeleteIcon, Delete as DeleteIcon,
} from '@material-ui/icons' } from '@material-ui/icons'
import { getPeerString, humanizeSize, shortenText } from 'utils/Utils' import { getPeerString, humanizeSize } from 'utils/Utils'
import { torrentsHost } from 'utils/Hosts' import { torrentsHost } from 'utils/Hosts'
import { NoImageIcon } from 'icons' import { NoImageIcon } from 'icons'
import DialogTorrentDetailsContent from 'components/DialogTorrentDetailsContent' import DialogTorrentDetailsContent from 'components/DialogTorrentDetailsContent'
@@ -42,7 +42,9 @@ const Torrent = ({ torrent }) => {
const getParsedTitle = () => { const getParsedTitle = () => {
const parse = key => ptt.parse(title || '')?.[key] || ptt.parse(name || '')?.[key] const parse = key => ptt.parse(title || '')?.[key] || ptt.parse(name || '')?.[key]
const titleStrings = [] const titleStrings = []
let parsedTitle = parse('title') let parsedTitle = parse('title')
const parsedYear = parse('year') const parsedYear = parse('year')
const parsedResolution = parse('resolution') const parsedResolution = parse('resolution')
@@ -90,7 +92,7 @@ const Torrent = ({ torrent }) => {
<TorrentCardDescription> <TorrentCardDescription>
<div className='description-title-wrapper'> <div className='description-title-wrapper'>
<div className='description-section-name'>{t('Name')}</div> <div className='description-section-name'>{t('Name')}</div>
<div className='description-torrent-title'>{shortenText(parsedTitle, 255)}</div> <div className='description-torrent-title'>{parsedTitle}</div>
</div> </div>
<div className='description-statistics-wrapper'> <div className='description-statistics-wrapper'>