diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-05-04 20:46:27 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-05-04 20:48:09 -0400 |
| commit | 7f9799c6693254f8eb6729c0977826694c28c437 (patch) | |
| tree | 48d119dfa78008b4c6fe44598eb38bf21da0c444 /src/utils/users.ts | |
| parent | c23feea922da063d88d031f25b72b53ba593ec04 (diff) | |
added navigation to profile
Diffstat (limited to 'src/utils/users.ts')
| -rw-r--r-- | src/utils/users.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index abadaf6e..c167ac2f 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -1,4 +1,6 @@ import AsyncStorage from '@react-native-community/async-storage'; +import {NavigationProp} from '@react-navigation/core'; +import {Dispatch} from 'react'; import {INTEGRATED_SOCIAL_LIST} from '../constants'; import {isUserBlocked, loadSocialPosts} from '../services'; import { @@ -199,3 +201,25 @@ export const canViewProfile = ( } return false; }; + +export const navigateToProfile = async ( + state: RootState, + dispatch: any, + navigation: any, + screenType: ScreenType, + user: UserType, +) => { + const loggedInUserId = state.user.user.userId; + const {userId, username} = user; + if (!userXInStore(state, screenType, userId)) { + await fetchUserX( + dispatch, + {userId: userId, username: username}, + screenType, + ); + } + navigation.push('Profile', { + userXId: userId === loggedInUserId ? undefined : userId, + screenType, + }); +}; |
