Unverified Commit 017787ef authored by Akinwale Ariwodola's avatar Akinwale Ariwodola Committed by GitHub
Browse files

optimise file page renders (#115)

parent d9ada93f
......@@ -291,25 +291,27 @@ class DiscoverPage extends React.PureComponent {
);
render() {
const { navigation, sortByItem, timeItem } = this.props;
const { currentRoute, navigation, sortByItem, timeItem } = this.props;
const { orderBy, showModalTagSelector, showSortPicker, showTimePicker } = this.state;
return (
<View style={discoverStyle.container}>
<UriBar navigation={navigation} belowOverlay={showModalTagSelector} />
<SectionList
ListHeaderComponent={this.sectionListHeader}
ListFooterComponent={this.sectionListFooter}
style={discoverStyle.scrollContainer}
contentContainerStyle={discoverStyle.scrollPadding}
initialNumToRender={4}
maxToRenderPerBatch={4}
removeClippedSubviews
renderItem={this.renderSectionListItem}
renderSectionHeader={this.renderSectionHeader}
sections={this.buildSections()}
keyExtractor={(item, index) => item}
/>
{currentRoute !== Constants.ROUTE_FILE && currentRoute !== Constants.DRAWER_ROUTE_FILE_VIEW && (
<SectionList
ListHeaderComponent={this.sectionListHeader}
ListFooterComponent={this.sectionListFooter}
style={discoverStyle.scrollContainer}
contentContainerStyle={discoverStyle.scrollPadding}
initialNumToRender={4}
maxToRenderPerBatch={4}
removeClippedSubviews
renderItem={this.renderSectionListItem}
renderSectionHeader={this.renderSectionHeader}
sections={this.buildSections()}
keyExtractor={(item, index) => item}
/>
)}
{!showModalTagSelector && !showSortPicker && !showTimePicker && (
<FloatingWalletBalance navigation={navigation} />
)}
......
......@@ -27,7 +27,6 @@ import {
selectPurchasedUris,
selectFailedPurchaseUris,
selectPurchaseUriErrorMessage,
selectIsSearching,
} from 'lbry-redux';
import {
doClaimEligiblePurchaseRewards,
......@@ -70,7 +69,6 @@ const select = (state, props) => {
streamingUrl: makeSelectStreamingUrlForUri(contentUri)(state),
thumbnail: makeSelectThumbnailForUri(contentUri)(state),
title: makeSelectTitleForUri(contentUri)(state),
isSearchingRecommendContent: selectIsSearching(state),
viewCount: makeSelectViewCountForUri(contentUri)(state),
};
};
......
......@@ -238,10 +238,42 @@ class FilePage extends React.PureComponent {
const { fileInfo: prevFileInfo } = this.props;
const { fileInfo } = nextProps;
return (
Object.keys(this.difference(nextProps, this.props)).length > 0 ||
Object.keys(this.difference(nextState, this.state)).length > 0
);
const propKeyTriggers = ['balance', 'viewCount', 'isResolvingUri'];
const stateKeyTriggers = [
'downloadPressed',
'fullscreenMode',
'mediaLoaded',
'playerBgHeighht',
'playerHeight',
'relatedY',
'showTipView',
'showImageViewer',
'showWebView',
'showDescription',
'showRecommended',
'uri',
];
for (let i = 0; i < propKeyTriggers.length; i++) {
const key = propKeyTriggers[i];
if (this.props[key] !== nextProps[key]) {
return true;
}
}
for (let i = 0; i < stateKeyTriggers.length; i++) {
const key = stateKeyTriggers[i];
if (this.state[key] !== nextState[key]) {
return true;
}
}
if (!prevFileInfo && fileInfo) {
return true;
}
if (prevFileInfo && fileInfo && Object.keys(this.difference(fileInfo, prevFileInfo)).length > 0) {
return true;
}
return false;
}
componentDidUpdate(prevProps, prevState) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment