aboutsummaryrefslogtreecommitdiff
path: root/src/components/profile
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2021-01-16 09:51:36 -0800
committerGitHub <noreply@github.com>2021-01-16 09:51:36 -0800
commit9711093bfa5810868e3cd17008bb7b3ddc7b9034 (patch)
tree6a8bb4341b1623cfc2da86af4b3b28c1fd3f8a44 /src/components/profile
parentd85eaeb878cbbeedda860ee5809b81100c910af2 (diff)
parent30391867438bb28cbcba9fc9ee2ff6d00027fd86 (diff)
Merge branch 'master' into tma538-friend-requests
Diffstat (limited to 'src/components/profile')
-rw-r--r--src/components/profile/Content.tsx28
-rw-r--r--src/components/profile/MomentMoreInfoDrawer.tsx7
-rw-r--r--src/components/profile/ProfilePreview.tsx19
3 files changed, 35 insertions, 19 deletions
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx
index 9213e012..e7fb566b 100644
--- a/src/components/profile/Content.tsx
+++ b/src/components/profile/Content.tsx
@@ -107,10 +107,12 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
const [shouldBounce, setShouldBounce] = useState<boolean>(true);
const [refreshing, setRefreshing] = useState<boolean>(false);
- //These two booleans are used to see if user closed the pormpt displayed to them
const [isStageTwoPromptClosed, setIsStageTwoPromptClosed] = useState<boolean>(
false,
);
+ const [isStageOnePromptClosed, setIsStageOnePromptClosed] = useState<boolean>(
+ false,
+ );
const [isStageThreePromptClosed, setIsStageThreePromptClosed] = useState<
boolean
>(false);
@@ -154,7 +156,7 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
const move = (direction: 'up' | 'down', title: string) => {
let categories = [...momentCategories];
categories = moveCategory(categories, title, direction === 'up');
- dispatch(updateMomentCategories(categories));
+ dispatch(updateMomentCategories(categories, false));
};
/**
@@ -173,11 +175,16 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
const navigateToMomentUploadPrompt = () => {
switch (profile.profile_completion_stage) {
case 1:
- if (momentCategories && momentCategories[0]) {
+ if (
+ momentCategories &&
+ momentCategories[0] &&
+ !isStageOnePromptClosed
+ ) {
navigation.navigate('MomentUploadPrompt', {
screenType,
momentCategory: momentCategories[0],
});
+ setIsStageOnePromptClosed(true);
}
break;
case 2:
@@ -190,8 +197,15 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
break;
}
};
- setTimeout(navigateToMomentUploadPrompt, 2000);
- }, [profile.profile_completion_stage, momentCategories]),
+ if (!userXId) {
+ setTimeout(navigateToMomentUploadPrompt, 2000);
+ }
+ }, [
+ profile.profile_completion_stage,
+ momentCategories,
+ userXId,
+ isStageOnePromptClosed,
+ ]),
);
useEffect(() => {
@@ -270,7 +284,7 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
momentCategories.filter((mc) => mc !== category),
false,
),
- );
+ )
dispatch(deleteUserMomentsForCategory(category));
},
},
@@ -379,7 +393,7 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => {
/>
),
)}
- {!userXId && profile.profile_completion_stage !== 1 && (
+ {!userXId && (
<TouchableOpacity
onPress={() =>
navigation.push('CategorySelection', {
diff --git a/src/components/profile/MomentMoreInfoDrawer.tsx b/src/components/profile/MomentMoreInfoDrawer.tsx
index e127e05c..77c349ca 100644
--- a/src/components/profile/MomentMoreInfoDrawer.tsx
+++ b/src/components/profile/MomentMoreInfoDrawer.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import {Alert, StyleSheet, TouchableOpacity, ViewProps} from 'react-native';
import MoreIcon from '../../assets/icons/more_horiz-24px.svg';
+import {ERROR_DELETE_MOMENT, MOMENT_DELETED_MSG} from '../../constants/strings';
import {deleteMoment, sendReport} from '../../services';
import {GenericMoreInfoDrawer} from '../common';
@@ -21,7 +22,7 @@ const MomentMoreInfoDrawer: React.FC<MomentMoreInfoDrawerProps> = (props) => {
if (success) {
// set time out for UI transitions
setTimeout(() => {
- Alert.alert('Moment deleted!', '', [
+ Alert.alert(MOMENT_DELETED_MSG, '', [
{
text: 'OK',
onPress: () => dismissScreenAndUpdate(),
@@ -31,9 +32,7 @@ const MomentMoreInfoDrawer: React.FC<MomentMoreInfoDrawerProps> = (props) => {
}, 500);
} else {
setTimeout(() => {
- Alert.alert(
- 'We were unable to delete that moment 😭 , please try again later!',
- );
+ Alert.alert(ERROR_DELETE_MOMENT);
}, 500);
}
});
diff --git a/src/components/profile/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx
index 0d8d9852..e6311daa 100644
--- a/src/components/profile/ProfilePreview.tsx
+++ b/src/components/profile/ProfilePreview.tsx
@@ -21,6 +21,7 @@ import {logout} from '../../store/actions';
import {checkIfUserIsBlocked, fetchUserX, userXInStore} from '../../utils';
import {SearchResultsBackground} from '../search';
import NavigationBar from 'src/routes/tabs';
+import {ERROR_UNABLE_TO_VIEW_PROFILE} from '../../constants/strings';
const NO_USER: UserType = {
userId: '',
@@ -90,7 +91,7 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({
loggedInUser,
);
if (isUserBlocked) {
- Alert.alert('You cannot view this profile');
+ Alert.alert(ERROR_UNABLE_TO_VIEW_PROFILE);
return;
}
if (previewType !== 'Comment') {
@@ -129,21 +130,23 @@ const ProfilePreview: React.FC<ProfilePreviewProps> = ({
}
}
+ const userXId =
+ loggedInUser.username === user.username ? undefined : user.id;
+
/**
- * Dispatch an event to Fetch the user details
- * If the user is already present in store, do not fetch again
- * Finally, Navigate to profile of the user selected
+ * Dispatch an event to Fetch the user details only if we're navigating to
+ * a userX's profile.
+ * If the user is already present in store, do not fetch again.
+ * Finally, Navigate to profile of the user selected.
*/
-
- if (!userXInStore(state, screenType, user.id)) {
+ if (userXId && !userXInStore(state, screenType, user.id)) {
await fetchUserX(
dispatch,
{userId: user.id, username: user.username},
screenType,
);
}
- const userXId =
- loggedInUser.username === user.username ? undefined : user.id;
+
navigation.push('Profile', {
userXId,
screenType,