From ff07db328a8c55226185436c2b316a2d875821e4 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Sat, 10 Apr 2021 22:38:28 +0500 Subject: [PATCH] upgraded to --- .../postsList/container/postsListContainer.tsx | 2 +- src/components/profile/profileView.js | 3 ++- src/components/tabbedPosts/container/tabbedPosts.tsx | 11 +++++++---- .../tabbedPosts/services/tabbedPostsModels.ts | 2 +- src/components/tabbedPosts/view/tabContent.tsx | 3 ++- src/screens/community/screen/communityScreen.js | 4 ++-- src/screens/feed/screen/feedScreen.js | 2 +- src/screens/tagResult/screen/tagResultScreen.js | 4 ++-- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/components/postsList/container/postsListContainer.tsx b/src/components/postsList/container/postsListContainer.tsx index 53b14bab0..e41410fe8 100644 --- a/src/components/postsList/container/postsListContainer.tsx +++ b/src/components/postsList/container/postsListContainer.tsx @@ -151,7 +151,7 @@ const postsListContainer = ({ data={posts} showsVerticalScrollIndicator={false} renderItem={_renderItem} - keyExtractor={(content) => content.permlink} + keyExtractor={(content) => `${content.author}/${content.permlink}`} removeClippedSubviews onEndReachedThreshold={1} maxToRenderPerBatch={3} diff --git a/src/components/profile/profileView.js b/src/components/profile/profileView.js index 90114ffa7..da0ab4c50 100644 --- a/src/components/profile/profileView.js +++ b/src/components/profile/profileView.js @@ -23,6 +23,7 @@ import { getFormatedCreatedDate } from '../../utils/time'; // Styles import styles from './profileStyles'; import globalStyles from '../../globalStyles'; +import { TabbedPosts } from '../tabbedPosts'; class ProfileView extends PureComponent { constructor(props) { @@ -191,7 +192,7 @@ class ProfileView extends PureComponent { tabLabel={this._getTabLabel(intl.formatMessage({ id: 'profile.post' }))} style={styles.postTabBar} > - ( @@ -42,10 +42,12 @@ export const TabbedPosts = ({ ) const [subFilters] = useState( - feedSubfilterOptions.map((label, index)=>({ + feedSubfilterOptions + ? feedSubfilterOptions.map((label, index)=>({ filterKey:feedSubfilterOptionsValue[index], label } as TabItem)) + : [] ) const [combinedFilters] = useState([...mainFilters, ...subFilters]); @@ -121,7 +123,7 @@ export const TabbedPosts = ({ shouldStack={isFeedScreen && feedUsername} firstStack={mainFilters} secondStack={subFilters} - initialFirstStackIndex={initialFilterIndex} + initialFirstStackIndex={selectedOptionIndex} onFilterSelect={_onFilterSelect} toggleHideImagesFlag={_toggleHideImagesFlag} /> @@ -132,6 +134,7 @@ export const TabbedPosts = ({ return ( {pages} diff --git a/src/components/tabbedPosts/services/tabbedPostsModels.ts b/src/components/tabbedPosts/services/tabbedPostsModels.ts index 992226993..669e9e0ed 100644 --- a/src/components/tabbedPosts/services/tabbedPostsModels.ts +++ b/src/components/tabbedPosts/services/tabbedPostsModels.ts @@ -4,7 +4,7 @@ export interface TabbedPostsProps { filterOptionsValue:string[], isFeedScreen:boolean, feedUsername:string, - initialFilterIndex:number, + selectedOptionIndex:number, feedSubfilterOptions:string[], feedSubfilterOptionsValue:string[], getFor:string, diff --git a/src/components/tabbedPosts/view/tabContent.tsx b/src/components/tabbedPosts/view/tabContent.tsx index 3d853d1a5..17dceb08f 100644 --- a/src/components/tabbedPosts/view/tabContent.tsx +++ b/src/components/tabbedPosts/view/tabContent.tsx @@ -60,9 +60,10 @@ const TabContent = ({ if (isFeedScreen) { AppState.addEventListener('change', _handleAppStateChange); - _initContent(true); } + _initContent(true); + return _cleanup; }, []) diff --git a/src/screens/community/screen/communityScreen.js b/src/screens/community/screen/communityScreen.js index f319f669f..d8086af32 100644 --- a/src/screens/community/screen/communityScreen.js +++ b/src/screens/community/screen/communityScreen.js @@ -3,7 +3,7 @@ import { View, Text } from 'react-native'; import { useIntl } from 'react-intl'; // Components -import { Posts, CollapsibleCard, Header, BasicHeader } from '../../../components'; +import { Posts, CollapsibleCard, Header, BasicHeader, TabbedPosts } from '../../../components'; import { Tag, ProfileSummaryPlaceHolder } from '../../../components/basicUIElements'; import CommunityContainer from '../container/communityContainer'; @@ -100,7 +100,7 @@ const CommunityScreen = ({ navigation }) => { )} - { feedSubfilterOptions={[...FEED_SUBFILTERS]} feedSubfilterOptionsValue={[...FEED_SUBFILTERS_VALUE]} getFor={get(currentAccount, 'name', null) ? 'feed' : 'hot'} - initialFilterIndex={get(currentAccount, 'name', null) ? 0 : 2} + selectedOptionIndex={get(currentAccount, 'name', null) ? 0 : 2} feedUsername={get(currentAccount, 'name', null)} isFeedScreen={true} /> diff --git a/src/screens/tagResult/screen/tagResultScreen.js b/src/screens/tagResult/screen/tagResultScreen.js index e38663774..6b7e53e2f 100644 --- a/src/screens/tagResult/screen/tagResultScreen.js +++ b/src/screens/tagResult/screen/tagResultScreen.js @@ -4,7 +4,7 @@ import ScrollableTabView from 'react-native-scrollable-tab-view'; import { useIntl } from 'react-intl'; // Components -import { SearchInput, Posts, TabBar } from '../../../components'; +import { SearchInput, Posts, TabBar, TabbedPosts } from '../../../components'; // Styles import styles from './tagResultStyles'; @@ -52,7 +52,7 @@ const TagResultScreen = ({ navigation }) => { -