lbry-desktop/ui/js/component/uriIndicator/view.jsx

70 lines
1.3 KiB
React
Raw Normal View History

2017-05-02 07:25:31 +02:00
import React from 'react';
import {Icon} from 'component/common';
2017-05-21 16:42:34 +02:00
class UriIndicator extends React.Component{
componentWillMount() {
this.resolve(this.props)
}
2017-05-02 07:25:31 +02:00
2017-05-21 16:42:34 +02:00
componentWillReceiveProps(nextProps) {
this.resolve(nextProps)
2017-05-10 05:06:48 +02:00
}
2017-05-21 16:42:34 +02:00
resolve(props) {
const {
isResolvingUri,
resolveUri,
claim,
uri,
} = props
2017-05-10 05:06:48 +02:00
2017-05-21 16:42:34 +02:00
if(!isResolvingUri && claim === undefined && uri) {
resolveUri(uri)
}
2017-05-02 07:25:31 +02:00
}
2017-05-21 16:42:34 +02:00
render() {
const {
claim,
uri,
isResolvingUri
} = this.props
if (isResolvingUri) {
return <span className="empty">Validating...</span>
}
if (!claim) {
return <span className="empty">Unused</span>
}
2017-05-02 07:25:31 +02:00
2017-05-21 16:42:34 +02:00
const {
channel_name: channelName,
has_signature: hasSignature,
signature_is_valid: signatureIsValid,
} = claim
if (!hasSignature || !channelName) {
return <span className="empty">Anonymous</span>;
}
let icon, modifier;
if (signatureIsValid) {
modifier = 'valid';
} else {
icon = 'icon-times-circle';
modifier = 'invalid';
}
return (
<span>
{channelName} {' '}
{ !signatureIsValid ?
<Icon icon={icon} className={`channel-indicator__icon channel-indicator__icon--${modifier}`} /> :
'' }
</span>
)
}
2017-05-02 07:25:31 +02:00
}
export default UriIndicator;