mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-29 08:21:30 +00:00
Simplify sorting logic in My Files
This commit is contained in:
parent
5a9d095a44
commit
304b53e994
1 changed files with 10 additions and 12 deletions
|
@ -175,7 +175,6 @@ var MyFilesPage = React.createClass({
|
||||||
},
|
},
|
||||||
title: function(filesInfo) {
|
title: function(filesInfo) {
|
||||||
return filesInfo.sort(function(a, b) {
|
return filesInfo.sort(function(a, b) {
|
||||||
console.log('in title sort. a is', a, '; b is', b)
|
|
||||||
return ((a.metadata ? a.metadata.title.toLowerCase() : a.name) >
|
return ((a.metadata ? a.metadata.title.toLowerCase() : a.name) >
|
||||||
(b.metadata ? b.metadata.title.toLowerCase() : b.name));
|
(b.metadata ? b.metadata.title.toLowerCase() : b.name));
|
||||||
});
|
});
|
||||||
|
@ -236,15 +235,9 @@ var MyFilesPage = React.createClass({
|
||||||
clearTimeout(this._fileTimeout);
|
clearTimeout(this._fileTimeout);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setFilesInfo: function(filesInfo) {
|
|
||||||
this.setState({
|
|
||||||
filesInfo: this._sortFunctions[this.state.sortBy](filesInfo),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
handleSortChanged: function(event) {
|
handleSortChanged: function(event) {
|
||||||
this.setState({
|
this.setState({
|
||||||
sortBy: event.target.value,
|
sortBy: event.target.value,
|
||||||
filesInfo: this._sortFunctions[event.target.value](this.state.filesInfo),
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateFilesInfo: function() {
|
updateFilesInfo: function() {
|
||||||
|
@ -263,7 +256,9 @@ var MyFilesPage = React.createClass({
|
||||||
newFilesInfo.push(fileInfo);
|
newFilesInfo.push(fileInfo);
|
||||||
}
|
}
|
||||||
if (claimInfoProcessedCount >= claimsInfo.length) {
|
if (claimInfoProcessedCount >= claimsInfo.length) {
|
||||||
this.setFilesInfo(newFilesInfo);
|
this.setState({
|
||||||
|
filesInfo: newFilesInfo,
|
||||||
|
});
|
||||||
|
|
||||||
this._fileTimeout = setTimeout(() => { this.updateFilesInfo() }, 1000);
|
this._fileTimeout = setTimeout(() => { this.updateFilesInfo() }, 1000);
|
||||||
}
|
}
|
||||||
|
@ -274,9 +269,11 @@ var MyFilesPage = React.createClass({
|
||||||
// We're in the Downloaded tab, so populate this.state.filesInfo with files the user has in
|
// We're in the Downloaded tab, so populate this.state.filesInfo with files the user has in
|
||||||
// lbrynet, with published files filtered out.
|
// lbrynet, with published files filtered out.
|
||||||
lbry.getFilesInfo((filesInfo) => {
|
lbry.getFilesInfo((filesInfo) => {
|
||||||
this.setFilesInfo(filesInfo.filter(({sd_hash}) => {
|
this.setState({
|
||||||
|
filesInfo: filesInfo.filter(({sd_hash}) => {
|
||||||
return this.state.publishedFilesSdHashes.indexOf(sd_hash) == -1;
|
return this.state.publishedFilesSdHashes.indexOf(sd_hash) == -1;
|
||||||
}));
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
let newFilesAvailable;
|
let newFilesAvailable;
|
||||||
if (!(this._fileInfoCheckNum % this._fileInfoCheckRate)) {
|
if (!(this._fileInfoCheckNum % this._fileInfoCheckRate)) {
|
||||||
|
@ -320,7 +317,8 @@ var MyFilesPage = React.createClass({
|
||||||
var content = [],
|
var content = [],
|
||||||
seenUris = {};
|
seenUris = {};
|
||||||
|
|
||||||
for (let fileInfo of this.state.filesInfo) {
|
const filesInfoSorted = this._sortFunctions[this.state.sortBy](this.state.filesInfo);
|
||||||
|
for (let fileInfo of filesInfoSorted) {
|
||||||
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, sd_hash} = fileInfo;
|
stopped, metadata, sd_hash} = fileInfo;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue