From 745eb2805c79ce7370ef484de93dcd6c83e8c2f7 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 18 May 2021 15:53:08 +0500 Subject: [PATCH] split profiles into profile and ownProfile page types --- src/components/posts/container/postsContainer.js | 7 +++++-- src/components/profile/profileView.js | 12 ++++-------- .../tabbedPosts/services/tabbedPostsFetch.ts | 2 +- .../tabbedPosts/services/tabbedPostsModels.ts | 2 +- src/components/tabbedPosts/view/stackedTabBar.tsx | 6 +++--- src/components/tabbedPosts/view/tabContent.tsx | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/components/posts/container/postsContainer.js b/src/components/posts/container/postsContainer.js index 4681c5513..73b60a642 100644 --- a/src/components/posts/container/postsContainer.js +++ b/src/components/posts/container/postsContainer.js @@ -477,7 +477,7 @@ const PostsContainer = ({ }; const _getPromotePosts = async () => { - if (pageType === 'profiles') { + if (pageType === 'profile' || pageType === 'ownProfile') { return; } await getPromotePosts() @@ -585,7 +585,10 @@ const PostsContainer = ({ sort: filter, }; - if (pageType === 'profiles' && (filter === 'feed' || filter === 'posts')) { + if ( + (pageType === 'profile' || pageType === 'ownProfile') && + (filter === 'feed' || filter === 'posts') + ) { options.sort = 'posts'; } } diff --git a/src/components/profile/profileView.js b/src/components/profile/profileView.js index b77e22fb6..501081530 100644 --- a/src/components/profile/profileView.js +++ b/src/components/profile/profileView.js @@ -1,8 +1,7 @@ -import React, { PureComponent, Fragment } from 'react'; -import { View, ScrollView, SafeAreaView, Text } from 'react-native'; +import React, { PureComponent } from 'react'; +import { View, ScrollView } from 'react-native'; import { injectIntl } from 'react-intl'; import get from 'lodash/get'; -import ScrollableTabView from 'react-native-scrollable-tab-view'; // Components import { CollapsibleCard } from '../collapsibleCard'; @@ -10,7 +9,6 @@ import { Comments } from '../comments'; import { Header } from '../header'; import { NoPost, ProfileSummaryPlaceHolder, WalletDetailsPlaceHolder } from '../basicUIElements'; import { ProfileSummary } from '../profileSummary'; -import { TabBar } from '../tabBar'; import { Wallet } from '../wallet'; // Constants @@ -18,8 +16,6 @@ import { PROFILE_FILTERS, PROFILE_FILTERS_OWN, PROFILE_FILTERS_VALUE, - PROFILE_SUBFILTERS, - PROFILE_SUBFILTERS_VALUE, } from '../../constants/options/filters'; // Utils @@ -27,7 +23,7 @@ import { getFormatedCreatedDate } from '../../utils/time'; // Styles import styles from './profileStyles'; -import globalStyles from '../../globalStyles'; + import { TabbedPosts } from '../tabbedPosts'; class ProfileView extends PureComponent { @@ -244,7 +240,7 @@ class ProfileView extends PureComponent { filterOptions={filterOptions} filterOptionsValue={PROFILE_FILTERS_VALUE} selectedOptionIndex={0} - pageType="profiles" + pageType={isOwnProfile ? 'ownProfile' : 'profile'} getFor="blog" feedUsername={username} key={username} diff --git a/src/components/tabbedPosts/services/tabbedPostsFetch.ts b/src/components/tabbedPosts/services/tabbedPostsFetch.ts index 6ce27525c..a6b864ba9 100644 --- a/src/components/tabbedPosts/services/tabbedPostsFetch.ts +++ b/src/components/tabbedPosts/services/tabbedPostsFetch.ts @@ -85,7 +85,7 @@ export const loadPosts = async ({ sort: filter, }; - if (pageType === 'profiles' && (filter === 'feed' || filter === 'posts')) { + if ((pageType === 'profile' || pageType === 'ownProfile') && (filter === 'feed' || filter === 'posts')) { options.sort = 'posts'; } } diff --git a/src/components/tabbedPosts/services/tabbedPostsModels.ts b/src/components/tabbedPosts/services/tabbedPostsModels.ts index 0b075cb6c..72bc55b38 100644 --- a/src/components/tabbedPosts/services/tabbedPostsModels.ts +++ b/src/components/tabbedPosts/services/tabbedPostsModels.ts @@ -8,7 +8,7 @@ export interface TabbedPostsProps { feedSubfilterOptions:string[], feedSubfilterOptionsValue:string[], getFor:string, - pageType:'main'|'community'|'profiles', + pageType:'main'|'community'|'profile'|'ownProfile', tag:string, forceLoadPosts:boolean, tabContentOverrides:Map, diff --git a/src/components/tabbedPosts/view/stackedTabBar.tsx b/src/components/tabbedPosts/view/stackedTabBar.tsx index 6a9d26020..dfd7098b6 100644 --- a/src/components/tabbedPosts/view/stackedTabBar.tsx +++ b/src/components/tabbedPosts/view/stackedTabBar.tsx @@ -14,7 +14,7 @@ interface StackedTabBarProps { activeTab:boolean; goToPage:(pageIndex)=>void; tabs:string[]; - pageType?:'main'|'community' + pageType?:'main'|'community'|'profile'|'ownProfile' shouldStack:boolean; firstStack:TabItem[]; secondStack:TabItem[]; @@ -47,7 +47,7 @@ export const StackedTabBar = ({ const [selectedFilterIndex, setSelectedFilterIndex] = useState(initialFirstStackIndex); const [selectedSecondStackIndex, setSelectedSecondStackIndex] = useState(0); - const enableCustomTabs = pageType === 'main' || pageType === 'community'; + const enableCustomTabs = pageType !== undefined; const _onCustomisePress = () => { @@ -109,7 +109,7 @@ export const StackedTabBar = ({ {enableCustomTabs && ( )} diff --git a/src/components/tabbedPosts/view/tabContent.tsx b/src/components/tabbedPosts/view/tabContent.tsx index 677603e40..66c0d0ca6 100644 --- a/src/components/tabbedPosts/view/tabContent.tsx +++ b/src/components/tabbedPosts/view/tabContent.tsx @@ -172,7 +172,7 @@ const TabContent = ({ const _getPromotedPosts = async () => { - if(pageType === 'profiles'){ + if(pageType === 'profile' || pageType === 'ownProfile'){ return; } const pPosts = await getPromotedPosts(username)