ca6d55da21
Extends lbryuri.build() and lbryuri.parse() to support special keys, contentName and channelName. These put the right values in the "name" and "path" position for both anonymous claims and channel content claims, which lets us write code that can deal with either type without special logic.
43 lines
No EOL
1.1 KiB
JavaScript
43 lines
No EOL
1.1 KiB
JavaScript
import React from 'react';
|
|
import lbry from '../lbry.js';
|
|
import lbryuri from '../lbryuri.js';
|
|
import {Icon} from './common.js';
|
|
|
|
const UriIndicator = React.createClass({
|
|
propTypes: {
|
|
uri: React.PropTypes.string.isRequired,
|
|
hasSignature: React.PropTypes.bool.isRequired,
|
|
signatureIsValid: React.PropTypes.bool,
|
|
},
|
|
render: function() {
|
|
|
|
const uriObj = lbryuri.parse(this.props.uri);
|
|
|
|
if (!this.props.hasSignature || !uriObj.isChannel) {
|
|
return <span className="empty">Anonymous</span>;
|
|
}
|
|
|
|
const channelUriObj = Object.assign({}, uriObj);
|
|
delete channelUriObj.path;
|
|
delete channelUriObj.contentName;
|
|
const channelUri = lbryuri.build(channelUriObj, false);
|
|
|
|
let icon, modifier;
|
|
if (this.props.signatureIsValid) {
|
|
modifier = 'valid';
|
|
} else {
|
|
icon = 'icon-times-circle';
|
|
modifier = 'invalid';
|
|
}
|
|
return (
|
|
<span>
|
|
{channelUri} {' '}
|
|
{ !this.props.signatureIsValid ?
|
|
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} /> :
|
|
'' }
|
|
</span>
|
|
);
|
|
}
|
|
});
|
|
|
|
export default UriIndicator; |