diff options
author | Ivan Chen <ivan@tagg.id> | 2021-05-05 18:36:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 18:36:39 -0400 |
commit | c9d32e68fbb9d1bc175722bfda49454a6f627eae (patch) | |
tree | 5f7b3cf0937ca073f03dde2f84ce5c0e50a038a3 /src/utils/users.ts | |
parent | d4a04e31144f6cfaebb0b892e3593bb02bd49ed5 (diff) | |
parent | 32a61c00756afb1aee0eb471ed643f24da1d3e85 (diff) |
Merge pull request #401 from IvanIFChen/tma296-add-mentions
[TMA-296] Add mentions
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r-- | src/utils/users.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index abadaf6e..754382b3 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -17,8 +17,8 @@ import {loadUserX} from './../store/actions/userX'; import {AppDispatch} from './../store/configureStore'; import {RootState} from './../store/rootReducer'; import { - ProfilePreviewType, ProfileInfoType, + ProfilePreviewType, ScreenType, UserType, } from './../types/types'; @@ -199,3 +199,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, + }); +}; |