Filter My Files results based on tab chosen
This commit is contained in:
parent
4072c1cdda
commit
8bc13fb8a5
1 changed files with 32 additions and 2 deletions
|
@ -134,6 +134,8 @@ var MyFilesRow = React.createClass({
|
||||||
var MyFilesPage = React.createClass({
|
var MyFilesPage = React.createClass({
|
||||||
_fileTimeout: null,
|
_fileTimeout: null,
|
||||||
_fileInfoCheckNum: 0,
|
_fileInfoCheckNum: 0,
|
||||||
|
_filesOwnership: {},
|
||||||
|
_filesOwnershipLoaded: false,
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
|
@ -141,10 +143,16 @@ var MyFilesPage = React.createClass({
|
||||||
filesAvailable: {},
|
filesAvailable: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
getDefaultProps: function() {
|
||||||
|
return {
|
||||||
|
show: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
document.title = "My Files";
|
document.title = "My Files";
|
||||||
},
|
},
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
this.getFilesOwnership();
|
||||||
this.updateFilesInfo();
|
this.updateFilesInfo();
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
@ -153,6 +161,27 @@ var MyFilesPage = React.createClass({
|
||||||
clearTimeout(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._filesOwnershipLoaded = true;
|
||||||
|
}
|
||||||
|
}, (err) => {
|
||||||
|
this._filesOwnership[fileInfo.lbry_uri] = true;
|
||||||
|
ownershipLoadedCount++;
|
||||||
|
if (ownershipLoadedCount >= filesInfo.length) {
|
||||||
|
this._filesOwnershipLoaded = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
updateFilesInfo: function() {
|
updateFilesInfo: function() {
|
||||||
lbry.getFilesInfo((filesInfo) => {
|
lbry.getFilesInfo((filesInfo) => {
|
||||||
if (!filesInfo) {
|
if (!filesInfo) {
|
||||||
|
@ -196,7 +225,7 @@ var MyFilesPage = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
if (this.state.filesInfo === null) {
|
if (this.state.filesInfo === null || !this._filesOwnershipLoaded) {
|
||||||
return (
|
return (
|
||||||
<main className="page">
|
<main className="page">
|
||||||
<BusyMessage message="Loading" />
|
<BusyMessage message="Loading" />
|
||||||
|
@ -214,7 +243,8 @@ var MyFilesPage = React.createClass({
|
||||||
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 || seenUris[lbry_uri])
|
if (!metadata || seenUris[lbry_uri] || (this.props.show == 'downloaded' && this._filesOwnership[lbry_uri]) ||
|
||||||
|
(this.props.show == 'published' && !this._filesOwnership[lbry_uri]))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue