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 && "| ✓"}