Fix downloads page

This commit is contained in:
Liam Cardenas 2018-02-21 11:01:43 -08:00
parent 3863c517fd
commit 4aee6d5f56
2 changed files with 26 additions and 26 deletions

View file

@ -20,10 +20,10 @@ class FileList extends React.PureComponent {
return fileInfos.slice().sort((fileInfo1, fileInfo2) => { return fileInfos.slice().sort((fileInfo1, fileInfo2) => {
const title1 = fileInfo1.value const title1 = fileInfo1.value
? fileInfo1.value.stream.metadata.title.toLowerCase() ? fileInfo1.value.stream.metadata.title.toLowerCase()
: fileInfo1.name; : fileInfo1.claim_name;
const title2 = fileInfo2.value const title2 = fileInfo2.value
? fileInfo2.value.stream.metadata.title.toLowerCase() ? fileInfo2.value.stream.metadata.title.toLowerCase()
: fileInfo2.name; : fileInfo2.claim_name;
if (title1 < title2) { if (title1 < title2) {
return -1; return -1;
} else if (title1 > title2) { } else if (title1 > title2) {
@ -51,7 +51,7 @@ class FileList extends React.PureComponent {
if (fileInfo.value) { if (fileInfo.value) {
return fileInfo.value.publisherSignature.certificateId; return fileInfo.value.publisherSignature.certificateId;
} }
return fileInfo.metadata.publisherSignature.certificateId; return fileInfo.channel_claim_id;
} }
handleSortChanged(event) { handleSortChanged(event) {
@ -70,11 +70,11 @@ class FileList extends React.PureComponent {
if (fileInfo.channel_name) { if (fileInfo.channel_name) {
uriParams.channelName = fileInfo.channel_name; uriParams.channelName = fileInfo.channel_name;
uriParams.contentName = fileInfo.name; uriParams.contentName = fileInfo.claim_name;
uriParams.claimId = this.getChannelSignature(fileInfo); uriParams.claimId = this.getChannelSignature(fileInfo);
} else { } else {
uriParams.claimId = fileInfo.claim_id; uriParams.claimId = fileInfo.claim_id;
uriParams.name = fileInfo.name; uriParams.claim_name = fileInfo.claim_name;
} }
const uri = buildURI(uriParams); const uri = buildURI(uriParams);

View file

@ -30,11 +30,11 @@ export function parseURI(URI, requireProto = false) {
// Break into components. Empty sub-matches are converted to null // Break into components. Empty sub-matches are converted to null
const componentsRegex = new RegExp( const componentsRegex = new RegExp(
'^((?:lbry://)?)' + // protocol '^((?: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) '([:$#]?)([^/]*)' + // modifier separator, modifier (stops at the first path separator or end)
'(/?)(.*)' // path separator, path '(/?)(.*)' // path separator, path
); );
const [proto, name, modSep, modVal, pathSep, path] = componentsRegex const [proto, claim_name, modSep, modVal, pathSep, path] = componentsRegex
.exec(URI) .exec(URI)
.slice(1) .slice(1)
.map(match => match || null); .map(match => match || null);
@ -47,12 +47,12 @@ export function parseURI(URI, requireProto = false) {
} }
// Validate and process name // Validate and process name
if (!name) { if (!claim_name) {
throw new Error(__('URI does not include name.')); throw new Error(__('URI does not include name.'));
} }
const isChannel = name.startsWith('@'); const isChannel = claim_name.startsWith('@');
const channelName = isChannel ? name.slice(1) : name; const channelName = isChannel ? claim_name.slice(1) : claim_name;
if (isChannel) { if (isChannel) {
if (!channelName) { if (!channelName) {
@ -66,7 +66,7 @@ export function parseURI(URI, requireProto = false) {
contentName = path; contentName = path;
} }
const nameBadChars = (channelName || name).match(regexInvalidURI); const nameBadChars = (channelName || claim_name).match(regexInvalidURI);
if (nameBadChars) { if (nameBadChars) {
throw new Error( throw new Error(
__( __(
@ -128,7 +128,7 @@ export function parseURI(URI, requireProto = false) {
} }
return { return {
name, claim_name,
path, path,
isChannel, isChannel,
...(contentName ? { contentName } : {}), ...(contentName ? { contentName } : {}),
@ -148,24 +148,24 @@ export function parseURI(URI, requireProto = false) {
export function buildURI(URIObj, includeProto = true) { export function buildURI(URIObj, includeProto = true) {
const { claimId, claimSequence, bidPosition, contentName, channelName } = URIObj; const { claimId, claimSequence, bidPosition, contentName, channelName } = URIObj;
let { name, path } = URIObj; let { claim_name, path } = URIObj;
if (channelName) { if (channelName) {
const channelNameFormatted = channelName.startsWith('@') ? channelName : `@${channelName}`; const channelNameFormatted = channelName.startsWith('@') ? channelName : `@${channelName}`;
if (!name) { if (!claim_name) {
name = channelNameFormatted; claim_name = channelNameFormatted;
} else if (name !== channelNameFormatted) { } else if (claim_name !== channelNameFormatted) {
throw new Error( 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 (contentName) {
if (!name) { if (!claim_name) {
name = contentName; claim_name = contentName;
} else if (!path) { } else if (!path) {
path = contentName; path = contentName;
} }
@ -180,7 +180,7 @@ export function buildURI(URIObj, includeProto = true) {
return ( return (
(includeProto ? 'lbry://' : '') + (includeProto ? 'lbry://' : '') +
name + claim_name +
(claimId ? `#${claimId}` : '') + (claimId ? `#${claimId}` : '') +
(claimSequence ? `:${claimSequence}` : '') + (claimSequence ? `:${claimSequence}` : '') +
(bidPosition ? `${bidPosition}` : '') + (bidPosition ? `${bidPosition}` : '') +
@ -192,8 +192,8 @@ export function buildURI(URIObj, includeProto = true) {
export function normalizeURI(URI) { export function normalizeURI(URI) {
if (URI.match(/pending_claim/)) return URI; if (URI.match(/pending_claim/)) return URI;
const { name, path, bidPosition, claimSequence, claimId } = parseURI(URI); const { claim_name, path, bidPosition, claimSequence, claimId } = parseURI(URI);
return buildURI({ name, path, claimSequence, bidPosition, claimId }); return buildURI({ claim_name, path, claimSequence, bidPosition, claimId });
} }
export function isURIValid(URI) { export function isURIValid(URI) {
@ -203,12 +203,12 @@ export function isURIValid(URI) {
} catch (error) { } catch (error) {
return false; 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'); const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i');
return regexp.test(name); return regexp.test(claim_name);
} }
export function isURIClaimable(URI) { export function isURIClaimable(URI) {
@ -220,7 +220,7 @@ export function isURIClaimable(URI) {
} }
return ( return (
parts && parts &&
parts.name && parts.claim_name &&
!parts.claimId && !parts.claimId &&
!parts.bidPosition && !parts.bidPosition &&
!parts.claimSequence && !parts.claimSequence &&