diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:00:39 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-29 14:00:39 -0400 |
| commit | e8324a7278a82d926acceedc10921f0b14e6d403 (patch) | |
| tree | 646e6771c70bea163c80909567cd785ccd25f3f1 /src/utils | |
| parent | 7ccb796e2cd25d48cbaee07c19b5f66e94859ba8 (diff) | |
updated helper function, cleaned up code, prevent friends navigation
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/users.ts | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts index 6cb6d46c..0b8a0582 100644 --- a/src/utils/users.ts +++ b/src/utils/users.ts @@ -176,9 +176,24 @@ export const defaultUserProfile = () => { }; export const canViewProfile = ( - ownProfile: boolean, - isPrivate: boolean, - isFriend: boolean, + state: RootState, + userXId: string | undefined, + screenType: ScreenType, ) => { - return ownProfile || isFriend || !isPrivate; + // own profile + if (!userXId || state.user.user.userId === userXId) { + return true; + } + // not private + if (!(userXId && state.userX[screenType][userXId].profile.is_private)) { + return true; + } + // is friend + if ( + userXId && + state.userX[screenType][userXId].profile.friendship_status === 'friends' + ) { + return true; + } + return false; }; |
