This file is uploading to Reflector. Reflector is a service that hosts a copy of the file on LBRY's servers so that it's available even if no one with the file is online.
}
)
}
{this.props.pending ? null :
}
);
}
});
var MyFilesPage = React.createClass({
_fileTimeout: null,
_fileInfoCheckNum: 0,
_filesOwnership: {},
getInitialState: function() {
return {
filesInfo: null,
filesOwnershipLoaded: false,
filesAvailable: {},
};
},
getDefaultProps: function() {
return {
show: null,
};
},
componentDidMount: function() {
document.title = "My Files";
},
componentWillMount: function() {
this.getFilesOwnership();
this.updateFilesInfo();
},
componentWillUnmount: function() {
if (this._fileTimeout)
{
clearTimeout(this._fileTimeout);
}
},
getFilesOwnership: function() {
lbry.getFilesInfo((filesInfo) => {
var ownershipLoadedCount = 0;
for (let i = 0; i < filesInfo.length; i++) {
let fileInfo = filesInfo[i];
lbry.call('get_my_claim', {name: fileInfo.lbry_uri}, (claim) => {
this._filesOwnership[fileInfo.lbry_uri] = false;
ownershipLoadedCount++;
if (ownershipLoadedCount >= filesInfo.length) {
this.setState({
filesOwnershipLoaded: true,
});
}
}, (err) => {
this._filesOwnership[fileInfo.lbry_uri] = true;
ownershipLoadedCount++;
if (ownershipLoadedCount >= filesInfo.length) {
this.setState({
filesOwnershipLoaded: true,
});
}
});
}
});
},
updateFilesInfo: function() {
lbry.getFilesInfo((filesInfo) => {
if (!filesInfo) {
filesInfo = [];
}
if (!(this._fileInfoCheckNum % 5)) {
// Time to update file availability status
for (let fileInfo of filesInfo) {
let name = fileInfo.lbry_uri;
lbry.search(name, (results) => {
var result = results[0];
var available = result.name == name && result.available;
if (typeof this.state.filesAvailable[name] === 'undefined' || available != this.state.filesAvailable[name]) {
var newFilesAvailable = Object.assign({}, this.state.filesAvailable);
newFilesAvailable[name] = available;
this.setState({
filesAvailable: newFilesAvailable,
});
}
});
}
}
this._fileInfoCheckNum += 1;
this.setState({
filesInfo: filesInfo,
});
this._fileTimeout = setTimeout(() => { this.updateFilesInfo() }, 1000);
});
},
render: function() {
if (this.state.filesInfo === null || !this.state.filesOwnershipLoaded) {
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] || (this.props.show == 'downloaded' && this._filesOwnership[lbry_uri]) ||
(this.props.show == 'published' && !this._filesOwnership[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 mediaType = lbry.getMediaType(metadata.content_type, file_name);
var showWatchButton = (mediaType == 'video');
content.push();
}
}
return (
{content}
);
}
});