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.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts
index 87bcbdfc..334cb3c0 100644
--- a/src/utils/users.ts
+++ b/src/utils/users.ts
@@ -18,8 +18,8 @@ import {loadUserX} from './../store/actions/userX';
import {AppDispatch} from './../store/configureStore';
import {RootState} from './../store/rootReducer';
import {
- ProfilePreviewType,
ProfileInfoType,
+ ProfilePreviewType,
ScreenType,
UserType,
UniversityBadge,
@@ -170,11 +170,6 @@ export const checkIfUserIsBlocked = async (
return await isUserBlocked(userId, loggedInUser.userId, token);
};
-export const defaultUserProfile = () => {
- const defaultImage = require('../assets/images/avatar-placeholder.png');
- return defaultImage;
-};
-
/**
* Used to determine whether the logged-in user is able to view userX's private
* information or not.
@@ -223,3 +218,25 @@ export const removeUserBadge = async (
dispatch(updateUserBadges(badges));
}
};
+
+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,
+ });
+};