Fix downloads page
This commit is contained in:
parent
3863c517fd
commit
4aee6d5f56
2 changed files with 26 additions and 26 deletions
|
@ -20,10 +20,10 @@ class FileList extends React.PureComponent {
|
|||
return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
|
||||
const title1 = fileInfo1.value
|
||||
? fileInfo1.value.stream.metadata.title.toLowerCase()
|
||||
: fileInfo1.name;
|
||||
: fileInfo1.claim_name;
|
||||
const title2 = fileInfo2.value
|
||||
? fileInfo2.value.stream.metadata.title.toLowerCase()
|
||||
: fileInfo2.name;
|
||||
: fileInfo2.claim_name;
|
||||
if (title1 < title2) {
|
||||
return -1;
|
||||
} else if (title1 > title2) {
|
||||
|
@ -51,7 +51,7 @@ class FileList extends React.PureComponent {
|
|||
if (fileInfo.value) {
|
||||
return fileInfo.value.publisherSignature.certificateId;
|
||||
}
|
||||
return fileInfo.metadata.publisherSignature.certificateId;
|
||||
return fileInfo.channel_claim_id;
|
||||
}
|
||||
|
||||
handleSortChanged(event) {
|
||||
|
@ -70,11 +70,11 @@ class FileList extends React.PureComponent {
|
|||
|
||||
if (fileInfo.channel_name) {
|
||||
uriParams.channelName = fileInfo.channel_name;
|
||||
uriParams.contentName = fileInfo.name;
|
||||
uriParams.contentName = fileInfo.claim_name;
|
||||
uriParams.claimId = this.getChannelSignature(fileInfo);
|
||||
} else {
|
||||
uriParams.claimId = fileInfo.claim_id;
|
||||
uriParams.name = fileInfo.name;
|
||||
uriParams.claim_name = fileInfo.claim_name;
|
||||
}
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ export function parseURI(URI, requireProto = false) {
|
|||
// Break into components. Empty sub-matches are converted to null
|
||||
const componentsRegex = new RegExp(
|
||||
'^((?:lbry://)?)' + // protocol
|
||||
'([^:$#/]*)' + // name (stops at the first separator or end)
|
||||
'([^:$#/]*)' + // claim name (stops at the first separator or end)
|
||||
'([:$#]?)([^/]*)' + // modifier separator, modifier (stops at the first path separator or end)
|
||||
'(/?)(.*)' // path separator, path
|
||||
);
|
||||
const [proto, name, modSep, modVal, pathSep, path] = componentsRegex
|
||||
const [proto, claim_name, modSep, modVal, pathSep, path] = componentsRegex
|
||||
.exec(URI)
|
||||
.slice(1)
|
||||
.map(match => match || null);
|
||||
|
@ -47,12 +47,12 @@ export function parseURI(URI, requireProto = false) {
|
|||
}
|
||||
|
||||
// Validate and process name
|
||||
if (!name) {
|
||||
if (!claim_name) {
|
||||
throw new Error(__('URI does not include name.'));
|
||||
}
|
||||
|
||||
const isChannel = name.startsWith('@');
|
||||
const channelName = isChannel ? name.slice(1) : name;
|
||||
const isChannel = claim_name.startsWith('@');
|
||||
const channelName = isChannel ? claim_name.slice(1) : claim_name;
|
||||
|
||||
if (isChannel) {
|
||||
if (!channelName) {
|
||||
|
@ -66,7 +66,7 @@ export function parseURI(URI, requireProto = false) {
|
|||
contentName = path;
|
||||
}
|
||||
|
||||
const nameBadChars = (channelName || name).match(regexInvalidURI);
|
||||
const nameBadChars = (channelName || claim_name).match(regexInvalidURI);
|
||||
if (nameBadChars) {
|
||||
throw new Error(
|
||||
__(
|
||||
|
@ -128,7 +128,7 @@ export function parseURI(URI, requireProto = false) {
|
|||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
claim_name,
|
||||
path,
|
||||
isChannel,
|
||||
...(contentName ? { contentName } : {}),
|
||||
|
@ -148,24 +148,24 @@ export function parseURI(URI, requireProto = false) {
|
|||
export function buildURI(URIObj, includeProto = true) {
|
||||
const { claimId, claimSequence, bidPosition, contentName, channelName } = URIObj;
|
||||
|
||||
let { name, path } = URIObj;
|
||||
let { claim_name, path } = URIObj;
|
||||
|
||||
if (channelName) {
|
||||
const channelNameFormatted = channelName.startsWith('@') ? channelName : `@${channelName}`;
|
||||
if (!name) {
|
||||
name = channelNameFormatted;
|
||||
} else if (name !== channelNameFormatted) {
|
||||
if (!claim_name) {
|
||||
claim_name = channelNameFormatted;
|
||||
} else if (claim_name !== channelNameFormatted) {
|
||||
throw new Error(
|
||||
__(
|
||||
'Received a channel content URI, but name and channelName do not match. "name" represents the value in the name position of the URI (lbry://name...), which for channel content will be the channel name. In most cases, to construct a channel URI you should just pass channelName and contentName.'
|
||||
'Received a channel content URI, but claim name and channelName do not match. "name" represents the value in the name position of the URI (lbry://name...), which for channel content will be the channel name. In most cases, to construct a channel URI you should just pass channelName and contentName.'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (contentName) {
|
||||
if (!name) {
|
||||
name = contentName;
|
||||
if (!claim_name) {
|
||||
claim_name = contentName;
|
||||
} else if (!path) {
|
||||
path = contentName;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ export function buildURI(URIObj, includeProto = true) {
|
|||
|
||||
return (
|
||||
(includeProto ? 'lbry://' : '') +
|
||||
name +
|
||||
claim_name +
|
||||
(claimId ? `#${claimId}` : '') +
|
||||
(claimSequence ? `:${claimSequence}` : '') +
|
||||
(bidPosition ? `${bidPosition}` : '') +
|
||||
|
@ -192,8 +192,8 @@ export function buildURI(URIObj, includeProto = true) {
|
|||
export function normalizeURI(URI) {
|
||||
if (URI.match(/pending_claim/)) return URI;
|
||||
|
||||
const { name, path, bidPosition, claimSequence, claimId } = parseURI(URI);
|
||||
return buildURI({ name, path, claimSequence, bidPosition, claimId });
|
||||
const { claim_name, path, bidPosition, claimSequence, claimId } = parseURI(URI);
|
||||
return buildURI({ claim_name, path, claimSequence, bidPosition, claimId });
|
||||
}
|
||||
|
||||
export function isURIValid(URI) {
|
||||
|
@ -203,12 +203,12 @@ export function isURIValid(URI) {
|
|||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
return parts && parts.name;
|
||||
return parts && parts.claim_name;
|
||||
}
|
||||
|
||||
export function isNameValid(name, checkCase = true) {
|
||||
export function isNameValid(claim_name, checkCase = true) {
|
||||
const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i');
|
||||
return regexp.test(name);
|
||||
return regexp.test(claim_name);
|
||||
}
|
||||
|
||||
export function isURIClaimable(URI) {
|
||||
|
@ -220,7 +220,7 @@ export function isURIClaimable(URI) {
|
|||
}
|
||||
return (
|
||||
parts &&
|
||||
parts.name &&
|
||||
parts.claim_name &&
|
||||
!parts.claimId &&
|
||||
!parts.bidPosition &&
|
||||
!parts.claimSequence &&
|
||||
|
|
Loading…
Reference in a new issue