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

View file

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

View file

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