Merge pull request #14 from lbryio/yet-more-fixes

fix related content. fix empty vertical claim list.
This commit is contained in:
Akinwale Ariwodola 2019-08-11 17:15:01 +01:00 committed by GitHub
commit 4bd26d4e2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 27 deletions

View file

@ -144,10 +144,6 @@ class ClaimList extends React.PureComponent {
};
handleVerticalEndReached = () => {
if (this.state.lastPageReached) {
return;
}
// fetch more content
const {
channelIds,
@ -161,8 +157,13 @@ class ClaimList extends React.PureComponent {
uris,
} = this.props;
const { subscriptionsView, trendingForAllView } = this.state;
if ((claimSearchUris && claimSearchUris.length >= softLimit) || (uris && uris.length >= softLimit)) {
// don't fetch more than the specified limit to be displayed
if (
this.state.lastPageReached ||
(claimSearchUris &&
(claimSearchUris.length < Constants.DEFAULT_PAGE_SIZE || claimSearchUris.length >= softLimit)) ||
(uris && uris.length >= softLimit)
) {
return;
}
@ -219,6 +220,12 @@ class ClaimList extends React.PureComponent {
);
};
verticalListEmptyComponent = () => {
return (
<Text style={claimListStyle.noContentText}>No content to display at this time. Please check back later.</Text>
);
};
renderVerticalItem = ({ item }) => {
const { navigation } = this.props;
return <FileListItem key={item} uri={item} style={claimListStyle.verticalListItem} navigation={navigation} />;
@ -259,16 +266,6 @@ class ClaimList extends React.PureComponent {
if (Constants.ORIENTATION_VERTICAL === orientation) {
const data = subscriptionsView || trendingForAllView ? claimSearchUris : uris;
if (!loading && !claimSearchLoading && (!data || data.length === 0)) {
return (
<View style={style}>
<Text style={claimListStyle.noContentText}>
No content to display at this time. Please check back later.
</Text>
</View>
);
}
return (
<View style={style}>
<FlatList
@ -276,6 +273,7 @@ class ClaimList extends React.PureComponent {
this.scrollView = ref;
}}
ListHeaderComponent={ListHeaderComponent}
ListEmptyComponent={loading || claimSearchLoading ? null : this.verticalListEmptyComponent}
style={claimListStyle.verticalScrollContainer}
contentContainerStyle={claimListStyle.verticalScrollPadding}
initialNumToRender={10}

View file

@ -1,5 +1,6 @@
import React from 'react';
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
import { normalizeURI } from 'lbry-redux';
import { navigateToUri } from 'utils/helper';
import Colors from 'styles/colors';
import FileListItem from 'component/fileListItem';
@ -41,7 +42,7 @@ export default class RelatedContent extends React.PureComponent {
didSearch;
render() {
const { recommendedContent, isSearching, navigation } = this.props;
const { recommendedContent, isSearching, navigation, uri, fullUri } = this.props;
if (!isSearching && (!recommendedContent || recommendedContent.length === 0)) {
return null;
@ -51,7 +52,9 @@ export default class RelatedContent extends React.PureComponent {
<View style={relatedContentStyle.container}>
<Text style={relatedContentStyle.title}>Related Content</Text>
{recommendedContent &&
recommendedContent.map(recommendedUri => (
recommendedContent
.filter(recommendedUri => recommendedUri !== normalizeURI(fullUri))
.map(recommendedUri => (
<FileListItem
style={fileListStyle.item}
key={recommendedUri}

View file

@ -637,6 +637,7 @@ class FilePage extends React.PureComponent {
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
const canSendTip = this.state.tipAmount > 0;
const fullUri = `${claim.name}#${claim.claim_id}`;
const fullChannelUri =
channelClaimId && channelClaimId.trim().length > 0
? normalizeURI(`${channelName}#${channelClaimId}`)
@ -959,7 +960,7 @@ class FilePage extends React.PureComponent {
{costInfo && parseFloat(costInfo.cost) > balance && <FileRewardsDriver navigation={navigation} />}
<View onLayout={this.setRelatedContentPosition} />
<RelatedContent navigation={navigation} uri={uri} />
<RelatedContent navigation={navigation} uri={uri} fullUri={fullUri} />
</ScrollView>
</View>
)}