implement lbry.getFileTitle function
fix sort by title on download / publish page
This commit is contained in:
parent
8c4f6eb46e
commit
63b496f7ca
2 changed files with 17 additions and 6 deletions
|
@ -1,4 +1,5 @@
|
|||
import React from 'react';
|
||||
import lbry from 'lbry.js';
|
||||
import { buildURI } from 'lbryURI';
|
||||
import FormField from 'component/formField';
|
||||
import FileTile from 'component/fileTile';
|
||||
|
@ -49,12 +50,8 @@ 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 title1 = lbry.getFileTitle(fileInfo1).toLowerCase();
|
||||
const title2 = lbry.getFileTitle(fileInfo2).toLowerCase();
|
||||
if (title1 < title2) {
|
||||
return -1;
|
||||
} else if (title1 > title2) {
|
||||
|
|
|
@ -204,6 +204,20 @@ Lbry.getAppVersionInfo = () =>
|
|||
ipcRenderer.send('version-info-requested');
|
||||
});
|
||||
|
||||
Lbry.getFileTitle = fileInfo => {
|
||||
const { value, metadata, claim_name, name } = fileInfo;
|
||||
if (metadata) {
|
||||
// downloaded claim
|
||||
return metadata.title || claim_name;
|
||||
} else if (value) {
|
||||
// published claim
|
||||
const { title } = value.stream.metadata;
|
||||
return title || name;
|
||||
}
|
||||
// Invalid claim
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in a new issue