From 140d405aa9752d0ee878cb01a099ffdc493a56ce Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sat, 19 May 2018 20:50:09 +0100 Subject: [PATCH] replaced FeaturedCategory with SectionList on discover page to improve performance --- app/src/component/featuredCategory/index.js | 7 ---- app/src/component/featuredCategory/view.js | 27 ------------- app/src/page/discover/view.js | 45 ++++++++++++--------- 3 files changed, 26 insertions(+), 53 deletions(-) delete mode 100644 app/src/component/featuredCategory/index.js delete mode 100644 app/src/component/featuredCategory/view.js diff --git a/app/src/component/featuredCategory/index.js b/app/src/component/featuredCategory/index.js deleted file mode 100644 index 7f4f5f1..0000000 --- a/app/src/component/featuredCategory/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import { connect } from 'react-redux'; -import FeaturedCategory from './view'; - -const select = state => ({}); -const perform = dispatch => ({}); - -export default connect(select, perform)(FeaturedCategory); diff --git a/app/src/component/featuredCategory/view.js b/app/src/component/featuredCategory/view.js deleted file mode 100644 index 874428a..0000000 --- a/app/src/component/featuredCategory/view.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react'; -import { Text, View } from 'react-native'; -import { normalizeURI } from 'lbry-redux'; -import FileItem from '../fileItem'; -import discoverStyle from '../../styles/discover'; - -class FeaturedCategory extends React.PureComponent { - render() { - const { category, names, categoryLink, navigation } = this.props; - - return ( - - {category} - {names && - names.map(name => ( - - ))} - - ); - } -} - -export default FeaturedCategory; \ No newline at end of file diff --git a/app/src/page/discover/view.js b/app/src/page/discover/view.js index 2c6be2b..155d1c9 100644 --- a/app/src/page/discover/view.js +++ b/app/src/page/discover/view.js @@ -1,8 +1,16 @@ import React from 'react'; -import FeaturedCategory from '../../component/featuredCategory'; import NavigationActions from 'react-navigation'; -import { AsyncStorage, NativeModules, ScrollView, Text, View } from 'react-native'; +import { + AsyncStorage, + NativeModules, + SectionList, + ScrollView, + Text, + View +} from 'react-native'; +import { normalizeURI } from 'lbry-redux'; import moment from 'moment'; +import FileItem from '../../component/fileItem'; import discoverStyle from '../../styles/discover'; import Feather from 'react-native-vector-icons/Feather'; @@ -34,7 +42,7 @@ class DiscoverPage extends React.PureComponent { } render() { - const { featuredUris, fetchingFeaturedUris } = this.props; + const { featuredUris, fetchingFeaturedUris, navigation } = this.props; const hasContent = typeof featuredUris === 'object' && Object.keys(featuredUris).length, failedToLoad = !fetchingFeaturedUris && !hasContent; @@ -42,22 +50,21 @@ class DiscoverPage extends React.PureComponent { {!hasContent && fetchingFeaturedUris && Fetching content...} {hasContent && - - {hasContent && - Object.keys(featuredUris).map( - category => - featuredUris[category].length ? ( - - ) : ( - '' - ) - )} - + ( + + ) + } + renderSectionHeader={ + ({section: {title}}) => ({title}) + } + sections={Object.keys(featuredUris).map(category => ({ title: category, data: featuredUris[category] }))} + keyExtractor={(item, index) => item} + /> } );