aboutsummaryrefslogtreecommitdiff
path: root/src/utils/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r--src/utils/users.ts24
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,
+ });
+};