Merge pull request #1956 from ecency/nt/profile-nav

navigation to profile tab or screen based on pageType
This commit is contained in:
Feruz M 2021-05-24 16:21:49 +03:00 committed by GitHub
commit a06dd94442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View File

@ -29,6 +29,7 @@ const PostCardContainer = ({
nsfw,
imageHeight,
setImageHeight,
pageType,
}) => {
const [_content, setContent] = useState(content);
const [reblogs, setReblogs] = useState([]);
@ -77,14 +78,21 @@ const PostCardContainer = ({
const _handleOnUserPress = () => {
if (_content) {
navigation.navigate({
routeName: ROUTES.SCREENS.PROFILE,
params: {
username: get(_content, 'author'),
reputation: get(_content, 'author_reputation'),
},
key: get(_content, 'author'),
});
if (
get(currentAccount, 'name') === get(_content, 'author') &&
(pageType === 'main' || pageType === 'ownProfile')
) {
navigation.navigate(ROUTES.TABBAR.PROFILE);
} else {
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;
isLoading:boolean;
isRefreshing:boolean;
pageType:'main'|'profile'|'ownProfile'|'community';
}
let _onEndReachedCalledDuringMomentum = true;
@ -26,6 +27,7 @@ const postsListContainer = ({
onLoadPosts,
isRefreshing,
isLoading,
pageType,
...props
}:postsListContainerProps, ref) => {
@ -121,6 +123,7 @@ const postsListContainer = ({
isHideImage={isHideImages}
imageHeight={imgHeight}
setImageHeight = {_setImageHeightInMap}
pageType={pageType}
/>,
);
}
@ -138,6 +141,7 @@ const postsListContainer = ({
isHideImage={isHideImages}
imageHeight={imgHeight}
setImageHeight = {_setImageHeightInMap}
pageType={pageType}
/>,
);
}

View File

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

View File

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