Merge pull request #184 from lbryio/fix-my-files-sort
Fix sorting on My Files page
This commit is contained in:
commit
4494b8f117
2 changed files with 22 additions and 8 deletions
|
@ -21,7 +21,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
|
|||
* On load screen, always show Cancel link if a previous page is available
|
||||
* When user hits "Watch," don't check balance if download already started
|
||||
* Restore UI version on Help page
|
||||
*
|
||||
* Fix sorting on My Files page
|
||||
|
||||
## [0.9.0rc9] - 2017-02-22
|
||||
### Changed
|
||||
|
|
|
@ -133,18 +133,32 @@ export let FileListPublished = React.createClass({
|
|||
export let FileList = React.createClass({
|
||||
_sortFunctions: {
|
||||
date: function(fileInfos) {
|
||||
return fileInfos.reverse();
|
||||
return fileInfos.slice().reverse();
|
||||
},
|
||||
title: function(fileInfos) {
|
||||
return fileInfos.sort(function(a, b) {
|
||||
return ((a.metadata ? a.metadata.title.toLowerCase() : a.name) >
|
||||
(b.metadata ? b.metadata.title.toLowerCase() : b.name));
|
||||
return fileInfos.slice().sort(function(fileInfo1, fileInfo2) {
|
||||
const title1 = fileInfo1.metadata ? fileInfo1.metadata.title.toLowerCase() : fileInfo1.name;
|
||||
const title2 = fileInfo2.metadata ? fileInfo2.metadata.title.toLowerCase() : fileInfo2.name;
|
||||
if (title1 < title2) {
|
||||
return -1;
|
||||
} else if (title1 > title2) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
},
|
||||
filename: function(fileInfos) {
|
||||
return fileInfos.sort(function(a, b) {
|
||||
return (a.file_name.toLowerCase() >
|
||||
b.file_name.toLowerCase());
|
||||
return fileInfos.slice().sort(function({file_name: fileName1}, {file_name: fileName2}) {
|
||||
const fileName1Lower = fileName1.toLowerCase();
|
||||
const fileName2Lower = fileName2.toLowerCase();
|
||||
if (fileName1Lower < fileName2Lower) {
|
||||
return -1;
|
||||
} else if (fileName2Lower > fileName1Lower) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue