navigation to profile tab or screen based on pageType

This commit is contained in:
Nouman Tahir 2021-05-24 17:40:57 +05:00
parent b746f1af2a
commit e7245c4ff1
4 changed files with 22 additions and 9 deletions

View File

@ -29,6 +29,7 @@ const PostCardContainer = ({
nsfw, nsfw,
imageHeight, imageHeight,
setImageHeight, setImageHeight,
pageType,
}) => { }) => {
const [_content, setContent] = useState(content); const [_content, setContent] = useState(content);
const [reblogs, setReblogs] = useState([]); const [reblogs, setReblogs] = useState([]);
@ -77,14 +78,21 @@ const PostCardContainer = ({
const _handleOnUserPress = () => { const _handleOnUserPress = () => {
if (_content) { if (_content) {
navigation.navigate({ if (
routeName: ROUTES.SCREENS.PROFILE, get(currentAccount, 'name') === get(_content, 'author') &&
params: { (pageType === 'main' || pageType === 'ownProfile')
username: get(_content, 'author'), ) {
reputation: get(_content, 'author_reputation'), navigation.navigate(ROUTES.TABBAR.PROFILE);
}, } else {
key: get(_content, 'author'), navigation.navigate({
}); routeName: ROUTES.SCREENS.PROFILE,
params: {
username: get(_content, 'author'),
reputation: get(_content, 'author_reputation'),
},
key: get(_content, 'author'),
});
}
} }
}; };

View File

@ -16,6 +16,7 @@ interface postsListContainerProps extends FlatListProps<any> {
onLoadPosts?:(shouldReset:boolean)=>void; onLoadPosts?:(shouldReset:boolean)=>void;
isLoading:boolean; isLoading:boolean;
isRefreshing:boolean; isRefreshing:boolean;
pageType:'main'|'profile'|'ownProfile'|'community';
} }
let _onEndReachedCalledDuringMomentum = true; let _onEndReachedCalledDuringMomentum = true;
@ -26,6 +27,7 @@ const postsListContainer = ({
onLoadPosts, onLoadPosts,
isRefreshing, isRefreshing,
isLoading, isLoading,
pageType,
...props ...props
}:postsListContainerProps, ref) => { }:postsListContainerProps, ref) => {
@ -121,6 +123,7 @@ const postsListContainer = ({
isHideImage={isHideImages} isHideImage={isHideImages}
imageHeight={imgHeight} imageHeight={imgHeight}
setImageHeight = {_setImageHeightInMap} setImageHeight = {_setImageHeightInMap}
pageType={pageType}
/>, />,
); );
} }
@ -138,6 +141,7 @@ const postsListContainer = ({
isHideImage={isHideImages} isHideImage={isHideImages}
imageHeight={imgHeight} imageHeight={imgHeight}
setImageHeight = {_setImageHeightInMap} setImageHeight = {_setImageHeightInMap}
pageType={pageType}
/>, />,
); );
} }

View File

@ -51,7 +51,7 @@ export interface TabMeta {
isFeedScreen:boolean, isFeedScreen:boolean,
isInitialTab:boolean, isInitialTab:boolean,
getFor:string, getFor:string,
pageType:string, pageType:'main'|'profile'|'ownProfile'|'community',
feedUsername:string, feedUsername:string,
tag:string, tag:string,
forceLoadPosts:boolean, forceLoadPosts:boolean,

View File

@ -281,6 +281,7 @@ const TabContent = ({
isRefreshing={tabMeta.isRefreshing} isRefreshing={tabMeta.isRefreshing}
isLoading={tabMeta.isLoading} isLoading={tabMeta.isLoading}
ListEmptyComponent={_renderEmptyContent} ListEmptyComponent={_renderEmptyContent}
pageType={pageType}
/> />
<NewPostsPopup <NewPostsPopup
popupAvatars={latestPosts.map(post=>post.avatar || '')} popupAvatars={latestPosts.map(post=>post.avatar || '')}