aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/comments/CommentsCount.tsx2
-rw-r--r--src/components/moments/Moment.tsx28
-rw-r--r--src/components/notifications/Notification.tsx42
-rw-r--r--src/components/profile/Content.tsx26
-rw-r--r--src/components/profile/ProfilePreview.tsx16
5 files changed, 87 insertions, 27 deletions
diff --git a/src/components/comments/CommentsCount.tsx b/src/components/comments/CommentsCount.tsx
index 325e2788..f4f8197d 100644
--- a/src/components/comments/CommentsCount.tsx
+++ b/src/components/comments/CommentsCount.tsx
@@ -30,7 +30,7 @@ const CommentsCount: React.FC<CommentsCountProps> = ({
};
return (
<>
- <TouchableOpacity onPress={() => navigateToCommentsScreen()}>
+ <TouchableOpacity onPress={navigateToCommentsScreen}>
<CommentIcon style={styles.image} />
<Text style={styles.count}>
{commentsCount !== '0' ? commentsCount : ''}
diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx
index 623e328d..6dbcd170 100644
--- a/src/components/moments/Moment.tsx
+++ b/src/components/moments/Moment.tsx
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
-import React from 'react';
+import React, {Fragment} from 'react';
import {
Alert,
StyleProp,
@@ -88,23 +88,15 @@ const Moment: React.FC<MomentProps> = ({
<Text style={[styles.titleText, externalStyles?.titleText]}>
{title}
</Text>
- <View style={styles.flexer} />
{!userXId ? (
<>
- <PlusIcon
- width={21}
- height={21}
- onPress={() => navigateToImagePicker()}
- color={TAGG_TEXT_LIGHT_BLUE}
- style={{marginRight: 10}}
- />
{showUpButton && move && (
<UpIcon
width={19}
height={19}
onPress={() => move('up', title)}
color={TAGG_TEXT_LIGHT_BLUE}
- style={{marginRight: 10}}
+ style={{marginLeft: 5}}
/>
)}
{showDownButton && move && (
@@ -113,9 +105,23 @@ const Moment: React.FC<MomentProps> = ({
height={19}
onPress={() => move('down', title)}
color={TAGG_TEXT_LIGHT_BLUE}
- style={{marginRight: 10}}
+ style={{marginLeft: 5}}
/>
)}
+ </>
+ ) : (
+ <Fragment />
+ )}
+ <View style={styles.flexer} />
+ {!userXId ? (
+ <>
+ <PlusIcon
+ width={21}
+ height={21}
+ onPress={() => navigateToImagePicker()}
+ color={TAGG_TEXT_LIGHT_BLUE}
+ style={{marginRight: 10}}
+ />
{shouldAllowDeletion && (
<DeleteIcon
onPress={() => handleMomentCategoryDelete(title)}
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx
index f6a04526..184e3f27 100644
--- a/src/components/notifications/Notification.tsx
+++ b/src/components/notifications/Notification.tsx
@@ -1,9 +1,22 @@
import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
-import {Image, StyleSheet, Text, View} from 'react-native';
+import {
+ ActivityIndicatorBase,
+ Alert,
+ Image,
+ StyleSheet,
+ Text,
+ View,
+} from 'react-native';
import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
-import {useDispatch, useStore} from 'react-redux';
+import {useDispatch, useSelector, useStore} from 'react-redux';
+import {MomentCommentsScreen} from '../../screens';
import {loadAvatar} from '../../services';
+import {
+ EMPTY_MOMENTS_LIST,
+ EMPTY_MOMENT_CATEGORIES,
+} from '../../store/initialStates';
+import {userSocialsReducer} from '../../store/reducers';
import {RootState} from '../../store/rootReducer';
import {NotificationType, ScreenType} from '../../types';
import {
@@ -15,6 +28,7 @@ import {
interface NotificationProps {
item: NotificationType;
+ userXId: string | undefined;
screenType: ScreenType;
}
@@ -27,11 +41,16 @@ const Notification: React.FC<NotificationProps> = (props) => {
notification_object,
unread,
},
+ userXId,
screenType,
} = props;
const navigation = useNavigation();
const state: RootState = useStore().getState();
const dispatch = useDispatch();
+ const {moments: loggedInUserMoments} =
+ notification_type === 'CMT'
+ ? useSelector((state: RootState) => state.moments)
+ : {moments: undefined};
const [avatarURI, setAvatarURI] = useState<string | undefined>(undefined);
const [momentURI, setMomentURI] = useState<string | undefined>(undefined);
@@ -81,6 +100,25 @@ const Notification: React.FC<NotificationProps> = (props) => {
screenType,
});
break;
+ case 'CMT':
+ // find the moment we need to display
+ const moment = loggedInUserMoments?.find(
+ (m) => m.moment_id === notification_object?.moment_id,
+ );
+ if (moment) {
+ navigation.push('IndividualMoment', {
+ moment,
+ userXId,
+ screenType,
+ });
+ setTimeout(() => {
+ navigation.push('MomentCommentsScreen', {
+ moment_id: moment.moment_id,
+ screenType,
+ });
+ }, 500);
+ }
+ break;
default:
break;
}
diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx
index 61a08d49..1d639a41 100644
--- a/src/components/profile/Content.tsx
+++ b/src/components/profile/Content.tsx
@@ -98,10 +98,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);
@@ -145,7 +147,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));
};
/**
@@ -164,11 +166,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:
@@ -181,8 +188,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,
+ ]),
);
/**
@@ -391,7 +405,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/ProfilePreview.tsx b/src/components/profile/ProfilePreview.tsx
index 6f008540..134e94cd 100644
--- a/src/components/profile/ProfilePreview.tsx
+++ b/src/components/profile/ProfilePreview.tsx
@@ -134,21 +134,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,