aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorankit-thanekar007 <ankit.thanekar007@gmail.com>2021-03-25 17:09:45 -0700
committerankit-thanekar007 <ankit.thanekar007@gmail.com>2021-03-25 17:09:45 -0700
commit82acd049763452decdab0c40e6cf7286dd2ed57d (patch)
treeca6af18b1cc9f3f4fbd54fb3e16470543c445e14 /src/components
parentf662d1cd85447de0f6be945a350d1f2d1be5033e (diff)
Private account toggle changes
Diffstat (limited to 'src/components')
-rw-r--r--src/components/profile/Content.tsx29
-rw-r--r--src/components/profile/PrivateProfile.tsx4
-rw-r--r--src/components/profile/ProfileBody.tsx1
-rw-r--r--src/components/profile/PublicProfile.tsx2
4 files changed, 26 insertions, 10 deletions
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx
index 860e16c5..8d77d798 100644
--- a/src/components/profile/Content.tsx
+++ b/src/components/profile/Content.tsx
@@ -41,7 +41,6 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
const {user = NO_USER, profile = NO_PROFILE} = userXId
? useSelector((state: RootState) => state.userX[screenType][userXId])
: useSelector((state: RootState) => state.user);
-
const {blockedUsers = EMPTY_PROFILE_PREVIEW_LIST} = useSelector(
(state: RootState) => state.blocked,
);
@@ -55,20 +54,19 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
*/
const [isFriend, setIsFriend] = useState<boolean>(false);
const [isBlocked, setIsBlocked] = useState<boolean>(false);
- const [isPrivate, setIsPrivate] = useState<boolean>(true);
const [profileBodyHeight, setProfileBodyHeight] = useState(0);
const [shouldBounce, setShouldBounce] = useState<boolean>(true);
const [refreshing, setRefreshing] = useState<boolean>(false);
const onRefresh = useCallback(() => {
const refrestState = async () => {
+ setRefreshing(true);
if (!userXId) {
await userLogin(dispatch, loggedInUser);
} else {
await fetchUserX(dispatch, user, screenType);
}
};
- setRefreshing(true);
refrestState().then(() => {
setRefreshing(false);
});
@@ -88,6 +86,10 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
}
}, [blockedUsers, user]);
+ useEffect(() => {
+ setIsFriend(profile.friendship_status === 'friends');
+ }, [profile.friendship_status]);
+
/**
* Handles a click on the block / unblock button.
* loadFriends updates friends list for the logged in user
@@ -108,6 +110,16 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
}
};
+ const canViewProfile = () => {
+ if (loggedInUser.userId === user.userId) {
+ return true;
+ } else if (profile.is_private && !isFriend) {
+ return false;
+ } else {
+ return true;
+ }
+ };
+
const handleScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
/**
* Set the new y position
@@ -153,13 +165,16 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
isBlocked,
}}
/>
- {isPrivate ? (
- <PrivateProfile />
- ) : (
+ {canViewProfile() ? (
<>
- <TaggsBar {...{y, profileBodyHeight, userXId, screenType}} />
+ <TaggsBar
+ {...{y, profileBodyHeight, userXId, screenType}}
+ whiteRing={undefined}
+ />
<PublicProfile {...{y, userXId, screenType}} />
</>
+ ) : (
+ <PrivateProfile />
)}
</Animated.ScrollView>
);
diff --git a/src/components/profile/PrivateProfile.tsx b/src/components/profile/PrivateProfile.tsx
index efa7ff39..07a0dccc 100644
--- a/src/components/profile/PrivateProfile.tsx
+++ b/src/components/profile/PrivateProfile.tsx
@@ -16,10 +16,10 @@ const PrivateProfile: React.FC = () => {
const styles = StyleSheet.create({
container: {
- backgroundColor: '#F9F9F9',
alignItems: 'center',
justifyContent: 'center',
- height: SCREEN_HEIGHT * 0.3,
+ backgroundColor: '#F9F9F9',
+ height: SCREEN_HEIGHT * 0.35,
},
privateAccountTextContainer: {marginTop: '8%'},
privateAccountTextStyle: {
diff --git a/src/components/profile/ProfileBody.tsx b/src/components/profile/ProfileBody.tsx
index 646be3e0..3aef5990 100644
--- a/src/components/profile/ProfileBody.tsx
+++ b/src/components/profile/ProfileBody.tsx
@@ -119,6 +119,7 @@ const styles = StyleSheet.create({
flex: 1,
paddingTop: '3.5%',
paddingBottom: '2%',
+ width: '50%',
},
container: {
paddingVertical: '1%',
diff --git a/src/components/profile/PublicProfile.tsx b/src/components/profile/PublicProfile.tsx
index f453d05b..4b5166f0 100644
--- a/src/components/profile/PublicProfile.tsx
+++ b/src/components/profile/PublicProfile.tsx
@@ -227,7 +227,7 @@ const PublicProfile: React.FC<ContentProps> = ({y, userXId, screenType}) => {
{!userXId && (
<TouchableOpacity
onPress={() =>
- navigation.push('CategorySelection', {
+ navigation.navigate('CategorySelection', {
screenType: CategorySelectionScreenType.Profile,
user: loggedInUser,
})