var moreMenuStyle = { position: 'absolute', display: 'block', top: '26px', left: '-13px', }; var MyFilesRowMoreMenu = React.createClass({ onRevealClicked: function() { lbry.revealFile(this.props.path); }, onRemoveClicked: function() { lbry.deleteFile(this.props.lbryUri, false); }, onDeleteClicked: function() { var alertText = 'Are you sure you\'d like to delete "' + this.props.title + '?" This will ' + (this.completed ? ' stop the download and ' : '') + 'permanently remove the file from your system.'; if (confirm(alertText)) { lbry.deleteFile(this.props.lbryUri); } }, render: function() { return (
{/* @TODO: Switch to OS specific wording */}
); } }); var moreButtonColumnStyle = { height: '120px', display: 'flex', alignItems: 'center', justifyContent: 'center', }, moreButtonContainerStyle = { display: 'block', position: 'relative', }, moreButtonStyle = { fontSize: '1.3em', }, progressBarStyle = { height: '15px', width: '230px', backgroundColor: '#444', border: '2px solid #eee', display: 'inline-block', }, artStyle = { maxHeight: '100px', display: 'block', marginLeft: 'auto', marginRight: 'auto', }; var MyFilesRow = React.createClass({ onPauseResumeClicked: function() { if (this.props.stopped) { lbry.startFile(this.props.lbryUri); } else { lbry.stopFile(this.props.lbryUri); } }, render: function() { //@TODO: Convert progress bar to reusable component var progressBarWidth = 230; if (this.props.completed) { var pauseLink = null; var curProgressBarStyle = {display: 'none'}; } else { var pauseLink = { this.onPauseResumeClicked() }} />; var curProgressBarStyle = Object.assign({}, progressBarStyle); curProgressBarStyle.width = Math.floor(this.props.ratioLoaded * progressBarWidth) + 'px'; curProgressBarStyle.borderRightWidth = progressBarWidth - Math.ceil(this.props.ratioLoaded * progressBarWidth) + 2; } if (this.props.showWatchButton) { var watchButton = } else { var watchButton = null; } return (
{this.props.imgUrl ? {'Photo : null}

{this.props.pending ? this.props.title : {this.props.title}}

{this.props.pending ? This file is pending confirmation : (
{ ' ' } {this.props.completed ? 'Download complete' : (parseInt(this.props.ratioLoaded * 100) + '%')}
{ pauseLink }
{ watchButton }
) }
{this.props.pending ? null :
}
); } }); var MyFilesPage = React.createClass({ fileTimeout: null, getInitialState: function() { return { filesInfo: null, }; }, componentDidMount: function() { document.title = "My Files"; }, componentWillMount: function() { this.updateFilesInfo(); }, componentWillUnmount: function() { if (this.fileTimeout) { clearTimeout(this.fileTimeout); } }, updateFilesInfo: function() { lbry.getFilesInfo((filesInfo) => { this.setState({ filesInfo: (filesInfo ? filesInfo : []), }); this.fileTimeout = setTimeout(() => { this.updateFilesInfo() }, 1000); }); }, render: function() { if (this.state.filesInfo === null) { return (
); } if (!this.state.filesInfo.length) { var content = You haven't downloaded anything from LBRY yet. Go !; } else { var content = [], seenUris = {}; for (let fileInfo of this.state.filesInfo) { let {completed, written_bytes, total_bytes, lbry_uri, file_name, download_path, stopped, metadata} = fileInfo; if (!metadata || seenUris[lbry_uri]) { continue; } seenUris[lbry_uri] = true; let {title, thumbnail} = metadata; if (!fileInfo.pending && typeof metadata == 'object') { var {title, thumbnail} = metadata; var pending = false; } else { var title = null; var thumbnail = null; var pending = true; } var ratioLoaded = written_bytes / total_bytes; var showWatchButton = (lbry.getMediaType(file_name) == 'video' || lbry.getMediaType(file_name) == 'audio'); content.push(); } } return (
{content}
); } });