diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/comments/CommentsCount.tsx | 2 | ||||
-rw-r--r-- | src/components/moments/Moment.tsx | 28 | ||||
-rw-r--r-- | src/components/notifications/Notification.tsx | 42 | ||||
-rw-r--r-- | src/components/profile/Content.tsx | 26 | ||||
-rw-r--r-- | src/components/profile/ProfilePreview.tsx | 16 | ||||
-rw-r--r-- | src/constants/regex.ts | 2 | ||||
-rw-r--r-- | src/screens/main/NotificationsScreen.tsx | 9 | ||||
-rw-r--r-- | src/screens/profile/EditProfile.tsx | 2 | ||||
-rw-r--r-- | src/screens/profile/ProfileScreen.tsx | 4 |
9 files changed, 99 insertions, 32 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, diff --git a/src/constants/regex.ts b/src/constants/regex.ts index 6ab045bd..fe5ce3ab 100644 --- a/src/constants/regex.ts +++ b/src/constants/regex.ts @@ -40,7 +40,7 @@ export const websiteRegex: RegExp = /^$|^(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._+ * - max. 150 chars for bio * - match alphanumerics, and special characters used in URLs */ -export const bioRegex: RegExp = /^$|^[A-Za-z0-9'\-,.!@#$%^&*()_:?/ ]{1,150}$/; +export const bioRegex: RegExp = /^[\s\S]{1,150}$/; /** * The gender regex has the following constraints diff --git a/src/screens/main/NotificationsScreen.tsx b/src/screens/main/NotificationsScreen.tsx index d6d47b02..8aa47299 100644 --- a/src/screens/main/NotificationsScreen.tsx +++ b/src/screens/main/NotificationsScreen.tsx @@ -17,6 +17,7 @@ import {NotificationType, ScreenType} from '../../types'; import {getDateAge, SCREEN_HEIGHT} from '../../utils'; const NotificationsScreen: React.FC = () => { + const {user: loggedInUser} = useSelector((state: RootState) => state.user); const [refreshing, setRefreshing] = useState(false); // used for figuring out which ones are unread const [lastViewed, setLastViewed] = useState<moment.Moment | undefined>( @@ -95,7 +96,13 @@ const NotificationsScreen: React.FC = () => { }, [lastViewed, notifications]); const renderNotification = ({item}: {item: NotificationType}) => ( - <Notification item={item} screenType={ScreenType.Notifications} /> + <Notification + item={item} + userXId={ + item.actor.id === loggedInUser.userId ? undefined : item.actor.id + } + screenType={ScreenType.Notifications} + /> ); const renderSectionHeader = ({section: {title, data}}) => diff --git a/src/screens/profile/EditProfile.tsx b/src/screens/profile/EditProfile.tsx index d86ae7cb..a6849c7a 100644 --- a/src/screens/profile/EditProfile.tsx +++ b/src/screens/profile/EditProfile.tsx @@ -442,7 +442,7 @@ const EditProfile: React.FC<EditProfileProps> = ({route, navigation}) => { valid={form.isValidBio} attemptedSubmit={form.attemptedSubmit} invalidWarning={ - 'Bio must be less than 150 characters and must contain valid characters' + 'Bio must be less than 150 characters' } width={280} value={form.bio} diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx index 1b9a1049..0ea96cd2 100644 --- a/src/screens/profile/ProfileScreen.tsx +++ b/src/screens/profile/ProfileScreen.tsx @@ -3,7 +3,7 @@ import {StatusBar} from 'react-native'; import Animated from 'react-native-reanimated'; import {Content, Cover, TabsGradient} from '../../components'; import {RouteProp, useFocusEffect} from '@react-navigation/native'; -import {ProfileStackParams} from '../../routes/'; +import {MainStackParams} from '../../routes/'; import {resetScreenType} from '../../store/actions'; import {useDispatch, useStore} from 'react-redux'; import {DUMMY_USERID} from '../../store/initialStates'; @@ -13,7 +13,7 @@ import {DUMMY_USERID} from '../../store/initialStates'; * including posts, messaging, and settings */ -type ProfileScreenRouteProps = RouteProp<ProfileStackParams, 'Profile'>; +type ProfileScreenRouteProps = RouteProp<MainStackParams, 'Profile'>; interface ProfileOnboardingProps { route: ProfileScreenRouteProps; |