aboutsummaryrefslogtreecommitdiff
path: root/src/utils/users.ts
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-07 16:01:47 -0400
committerIvan Chen <ivan@tagg.id>2021-05-07 16:01:47 -0400
commit76bc8c5825f39257be6e7648d12b858f1e805569 (patch)
treeb94d9570439ebfa42e6664144f124abe5d4113e3 /src/utils/users.ts
parent65c7411f4609edac3d4d5f23fc031ed274fc5872 (diff)
parentc9d32e68fbb9d1bc175722bfda49454a6f627eae (diff)
Merge branch 'master' into tma821-load-badges-faster-ft
# Conflicts: # src/utils/users.ts
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,
+ });
+};