use full URIs for channelname links

This commit is contained in:
Akinwale Ariwodola 2019-02-11 11:56:14 +01:00
parent 1731462b41
commit 918a7e64bd
3 changed files with 12 additions and 11 deletions

View file

@ -51,6 +51,8 @@ class FileItem extends React.PureComponent {
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
const channelName = claim ? claim.channel_name : null;
const channelClaimId = claim && claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
const height = claim ? claim.height : null;
return (
@ -76,8 +78,7 @@ class FileItem extends React.PureComponent {
<View style={discoverStyle.detailsRow}>
{channelName &&
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
const channelUri = normalizeURI(channelName);
navigateToUri(navigation, channelUri);
navigateToUri(navigation, normalizeURI(fullChannelUri));
}} />}
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo block={height} />
</View>

View file

@ -63,11 +63,13 @@ class FileListItem extends React.PureComponent {
const isResolving = !fileInfo && isResolvingUri;
const title = fileInfo ? fileInfo.metadata.title : metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
let name, channel, height;
let name, channel, height, channelClaimId, fullChannelUri;
if (claim) {
name = claim.name;
channel = claim.channel_name;
height = claim.height;
channelClaimId = claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
}
return (
@ -90,8 +92,7 @@ class FileListItem extends React.PureComponent {
{(title || name) && <Text style={fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
{channel &&
<Link style={fileListStyle.publisher} text={channel} onPress={() => {
const channelUri = normalizeURI(channel);
navigateToUri(navigation, channelUri);
navigateToUri(navigation, normalizeURI(fullChannelUri));
}} />}
<View style={fileListStyle.info}>

View file

@ -428,9 +428,9 @@ class FilePage extends React.PureComponent {
const { height, channel_name: channelName, value } = claim;
const showActions = !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView;
const showFileActions = (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId =
value && value.publisherSignature && value.publisherSignature.certificateId;
const channelClaimId = value && value.publisherSignature && value.publisherSignature.certificateId;
const canSendTip = this.state.tipAmount > 0;
const fullChannelUri = channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
const playerStyle = [filePageStyle.player,
this.state.isLandscape ? filePageStyle.containedPlayerLandscape :
@ -575,8 +575,7 @@ class FilePage extends React.PureComponent {
numberOfLines={1}
ellipsizeMode={"tail"}
onPress={() => {
const channelUri = normalizeURI(channelName);
navigateToUri(navigation, channelUri);
navigateToUri(navigation, normalizeURI(fullChannelUri));
}} />
<DateTime
style={filePageStyle.publishDate}
@ -588,11 +587,11 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.subscriptionRow}>
<SubscribeButton
style={filePageStyle.actionButton}
uri={channelUri}
uri={fullChannelUri}
name={channelName} />
<SubscribeNotificationButton
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
uri={channelUri}
uri={fullChannelUri}
name={channelName} />
</View>
</View>