From b9bf84870dd14659ba86582fa341b7e1078e4f19 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 25 Feb 2021 14:05:14 +0300 Subject: [PATCH] add viewed --- web/src/components/DialogTorrentInfo.js | 36 +++++++++++++++++++++++-- web/src/utils/Hosts.js | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/web/src/components/DialogTorrentInfo.js b/web/src/components/DialogTorrentInfo.js index 958f584..d0c8efe 100644 --- a/web/src/components/DialogTorrentInfo.js +++ b/web/src/components/DialogTorrentInfo.js @@ -5,7 +5,7 @@ import CachedIcon from '@material-ui/icons/Cached' import LinearProgress from '@material-ui/core/LinearProgress'; import { getPeerString, humanizeSize } from '../utils/Utils' -import { playlistTorrHost, streamHost } from '../utils/Hosts' +import { playlistTorrHost, streamHost, viewedHost } from '../utils/Hosts' import DialogTitle from '@material-ui/core/DialogTitle' import DialogContent from '@material-ui/core/DialogContent' @@ -25,12 +25,20 @@ const style = { export default function DialogTorrentInfo(props) { const [torrent, setTorrent] = React.useState(props.torrent) + const [viewed, setViewed] = React.useState(null) const [progress, setProgress] = React.useState(-1) useEffect(() => { setTorrent(props.torrent) if(torrent.stat==2) setProgress(torrent.preloaded_bytes * 100 / torrent.preload_size) + getViewed(props.torrent.hash,(list) => { + if (list) { + let lst = list.map((itm) => itm.file_index) + setViewed(lst) + }else + setViewed(null) + }) }, [props.torrent, props.open]) return ( @@ -74,7 +82,7 @@ export default function DialogTorrentInfo(props) { href={streamHost() + '/' + encodeURIComponent(file.path.split('\\').pop().split('/').pop()) + '?link=' + torrent.hash + '&index=' + file.id + '&play'} > - {file.path.split('\\').pop().split('/').pop()} | {humanizeSize(file.length)} + {file.path.split('\\').pop().split('/').pop()} | {humanizeSize(file.length)} {viewed && viewed.indexOf(file.id)!=-1 && "| ✓"}