Fix sort by title #1172

Merged
btzr-io merged 4 commits from fix-sort-title into master 2018-03-29 21:28:20 +02:00
2 changed files with 23 additions and 14 deletions

View file

@ -49,12 +49,21 @@ class FileList extends React.PureComponent {
: fileInfos,
title: fileInfos =>
fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const title1 = fileInfo1.value
? fileInfo1.value.stream.metadata.title.toLowerCase()
: fileInfo1.claim_name;
const title2 = fileInfo2.value
? fileInfo2.value.stream.metadata.title.toLowerCase()
: fileInfo2.claim_name;
const getFileTitle = fileInfo => {
const { value, metadata, name, claim_name: claimName } = fileInfo;
if (metadata) {
// downloaded claim
return metadata.title || claimName;
} else if (value) {
// published claim
const { title } = value.stream.metadata;
return title || name;
}
// Invalid claim
return '';
};
const title1 = getFileTitle(fileInfo1).toLowerCase();
const title2 = getFileTitle(fileInfo2).toLowerCase();
if (title1 < title2) {
return -1;
} else if (title1 > title2) {

View file

@ -174,6 +174,14 @@ Lbry.publishDeprecated = (params, fileListedCallback, publishedCallback, errorCa
Lbry.imagePath = file => `${staticResourcesPath}/img/${file}`;
Lbry.getAppVersionInfo = () =>
new Promise(resolve => {
ipcRenderer.once('version-info-received', (event, versionInfo) => {
resolve(versionInfo);
});
ipcRenderer.send('version-info-requested');
});
Lbry.getMediaType = (contentType, fileName) => {
if (contentType) {
return /^[^/]+/.exec(contentType)[0];
@ -196,14 +204,6 @@ Lbry.getMediaType = (contentType, fileName) => {
return 'unknown';
};
Lbry.getAppVersionInfo = () =>
new Promise(resolve => {
ipcRenderer.once('version-info-received', (event, versionInfo) => {
resolve(versionInfo);
});
ipcRenderer.send('version-info-requested');
});
/**
* Wrappers for API methods to simulate missing or future behavior. Unlike the old-style stubs,
* these are designed to be transparent wrappers around the corresponding API methods.