only print an item in my_files once

This commit is contained in:
Jeremy Kauffman 2016-08-07 11:29:08 -04:00 committed by Alex Liebowitz
parent ad3773ead4
commit 78f1fde34b

View file

@ -151,16 +151,19 @@ var MyFilesPage = React.createClass({
var content = <span>You haven't downloaded anything from LBRY yet. Go <Link href="/" label="search for your first download" />!</span>; var content = <span>You haven't downloaded anything from LBRY yet. Go <Link href="/" label="search for your first download" />!</span>;
} else { } else {
var content = [], var content = [],
keyIndex = 0; seenUris = {};
for (let fileInfo of this.state.filesInfo) { for (let fileInfo of this.state.filesInfo) {
let {completed, written_bytes, total_bytes, lbry_uri, file_name, download_path, let {completed, written_bytes, total_bytes, lbry_uri, file_name, download_path,
stopped, metadata} = fileInfo; stopped, metadata} = fileInfo;
if (!metadata) if (!metadata || seenUris[lbry_uri])
{ {
continue; continue;
} }
seenUris[lbry_uri] = true;
let {title, thumbnail} = metadata; let {title, thumbnail} = metadata;
if (!fileInfo.pending && typeof metadata == 'object') { if (!fileInfo.pending && typeof metadata == 'object') {
@ -175,7 +178,7 @@ var MyFilesPage = React.createClass({
var ratioLoaded = written_bytes / total_bytes; var ratioLoaded = written_bytes / total_bytes;
var showWatchButton = (lbry.getMediaType(file_name) == 'video' || lbry.getMediaType(file_name) == 'audio'); var showWatchButton = (lbry.getMediaType(file_name) == 'video' || lbry.getMediaType(file_name) == 'audio');
content.push(<MyFilesRow key={lbry_uri + (++keyIndex)} lbryUri={lbry_uri} title={title || ('lbry://' + lbry_uri)} completed={completed} stopped={stopped} content.push(<MyFilesRow key={lbry_uri} lbryUri={lbry_uri} title={title || ('lbry://' + lbry_uri)} completed={completed} stopped={stopped}
ratioLoaded={ratioLoaded} imgUrl={thumbnail} path={download_path} ratioLoaded={ratioLoaded} imgUrl={thumbnail} path={download_path}
showWatchButton={showWatchButton} pending={pending} />); showWatchButton={showWatchButton} pending={pending} />);
} }