diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/moments/IndividualMomentTitleBar.tsx | 9 | ||||
-rw-r--r-- | src/components/moments/MomentPostHeader.tsx | 29 | ||||
-rw-r--r-- | src/components/notifications/Notification.tsx | 45 | ||||
-rw-r--r-- | src/components/profile/Content.tsx | 12 | ||||
-rw-r--r-- | src/constants/constants.ts | 15 | ||||
-rw-r--r-- | src/services/ExploreService.ts | 37 | ||||
-rw-r--r-- | src/store/actions/taggUsers.ts | 3 | ||||
-rw-r--r-- | src/types/types.ts | 9 |
8 files changed, 74 insertions, 85 deletions
diff --git a/src/components/moments/IndividualMomentTitleBar.tsx b/src/components/moments/IndividualMomentTitleBar.tsx index 88e0c308..79453ade 100644 --- a/src/components/moments/IndividualMomentTitleBar.tsx +++ b/src/components/moments/IndividualMomentTitleBar.tsx @@ -29,14 +29,14 @@ const styles = StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', - justifyContent: 'center', + justifyContent: 'flex-start', height: '5%', }, headerContainer: { - flexShrink: 1, - marginLeft: '11%', + width: '80%', }, header: { + textAlign: 'center', color: 'white', fontSize: normalize(18), fontWeight: '700', @@ -44,10 +44,9 @@ const styles = StyleSheet.create({ letterSpacing: normalize(1.3), }, closeButton: { - position: 'absolute', height: '50%', aspectRatio: 1, - left: '3%', + left: '8%', }, }); diff --git a/src/components/moments/MomentPostHeader.tsx b/src/components/moments/MomentPostHeader.tsx index aad776e8..ff324c4a 100644 --- a/src/components/moments/MomentPostHeader.tsx +++ b/src/components/moments/MomentPostHeader.tsx @@ -1,12 +1,19 @@ import React, {useState} from 'react'; -import {StyleSheet, Text, View, ViewProps} from 'react-native'; +import { + StyleSheet, + Text, + TouchableOpacity, + View, + ViewProps, +} from 'react-native'; import {MomentMoreInfoDrawer} from '../profile'; import {loadUserMoments} from '../../store/actions'; -import {useDispatch, useSelector} from 'react-redux'; +import {useDispatch, useSelector, useStore} from 'react-redux'; import {ScreenType} from '../../types'; import Avatar from '../profile/Avatar'; import {useNavigation} from '@react-navigation/native'; import {RootState} from '../../store/rootReducer'; +import {fetchUserX, userXInStore} from '../../utils'; interface MomentPostHeaderProps extends ViewProps { userXId?: string; @@ -24,22 +31,36 @@ const MomentPostHeader: React.FC<MomentPostHeaderProps> = ({ }) => { const [drawerVisible, setDrawerVisible] = useState(false); const dispatch = useDispatch(); + const state: RootState = useStore().getState(); const navigation = useNavigation(); const {userId: loggedInUserId, username: loggedInUserName} = useSelector( (state: RootState) => state.user.user, ); const isOwnProfile = loggedInUserName === username; + const navigateToProfile = async () => { + if (userXId && !userXInStore(state, screenType, userXId)) { + await fetchUserX( + dispatch, + {userId: userXId, username: username}, + screenType, + ); + } + navigation.navigate('Profile', { + userXId: isOwnProfile ? undefined : userXId, + screenType, + }); + }; return ( <View style={[styles.container, style]}> - <View style={styles.header}> + <TouchableOpacity onPress={navigateToProfile} style={styles.header}> <Avatar style={styles.avatar} userXId={userXId} screenType={screenType} /> <Text style={styles.headerText}>{username}</Text> - </View> + </TouchableOpacity> <MomentMoreInfoDrawer isOpen={drawerVisible} setIsOpen={setDrawerVisible} diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index c8a8aa06..8143e396 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -205,11 +205,22 @@ const Notification: React.FC<NotificationProps> = (props) => { dispatch(loadUserNotifications()); }; + const isOwnProfile = id === loggedInUser.userId; + const navigateToProfile = async () => { + if (!userXInStore(state, screenType, id)) { + await fetchUserX(dispatch, {userId: id, username: username}, screenType); + } + navigation.navigate('Profile', { + userXId: isOwnProfile ? undefined : id, + screenType, + }); + }; + const renderContent = () => ( - <TouchableWithoutFeedback - style={styles.container} - onPress={onNotificationTap}> - <View style={styles.avatarContainer}> + <View style={styles.container}> + <TouchableWithoutFeedback + onPress={navigateToProfile} + style={styles.avatarContainer}> <Image style={styles.avatar} source={ @@ -218,12 +229,16 @@ const Notification: React.FC<NotificationProps> = (props) => { : require('../../assets/images/avatar-placeholder.png') } /> - </View> + </TouchableWithoutFeedback> <View style={styles.contentContainer}> - <Text style={styles.actorName}> - {first_name} {last_name} - </Text> - <Text>{verbage}</Text> + <TouchableWithoutFeedback onPress={navigateToProfile}> + <Text style={styles.actorName}> + {first_name} {last_name} + </Text> + </TouchableWithoutFeedback> + <TouchableWithoutFeedback onPress={onNotificationTap}> + <Text>{verbage}</Text> + </TouchableWithoutFeedback> </View> {notification_type === 'FRD_REQ' && ( <View style={styles.buttonsContainer}> @@ -238,9 +253,13 @@ const Notification: React.FC<NotificationProps> = (props) => { notification_type === 'MOM_3+' || notification_type === 'MOM_FRIEND') && notification_object && ( - <Image style={styles.moment} source={{uri: momentURI}} /> + <TouchableWithoutFeedback + style={styles.moment} + onPress={onNotificationTap}> + <Image style={styles.imageFlex} source={{uri: momentURI}} /> + </TouchableWithoutFeedback> )} - </TouchableWithoutFeedback> + </View> ); return unread ? ( @@ -284,7 +303,6 @@ const styles = StyleSheet.create({ fontWeight: '700', }, moment: { - position: 'absolute', height: 42, width: 42, right: '5%', @@ -292,6 +310,9 @@ const styles = StyleSheet.create({ buttonsContainer: { height: '80%', }, + imageFlex: { + flex: 1, + }, }); export default Notification; diff --git a/src/components/profile/Content.tsx b/src/components/profile/Content.tsx index d4c50d5c..1a5a205c 100644 --- a/src/components/profile/Content.tsx +++ b/src/components/profile/Content.tsx @@ -109,9 +109,10 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => { const [isStageOnePromptClosed, setIsStageOnePromptClosed] = useState<boolean>( false, ); - const [isStageThreePromptClosed, setIsStageThreePromptClosed] = useState< - boolean - >(false); + const [ + isStageThreePromptClosed, + setIsStageThreePromptClosed, + ] = useState<boolean>(false); const onRefresh = useCallback(() => { const refrestState = async () => { @@ -308,7 +309,10 @@ const Content: React.FC<ContentProps> = ({y, userXId, screenType}) => { isBlocked, }} /> - <TaggsBar {...{y, profileBodyHeight, userXId, screenType}} /> + <TaggsBar + {...{y, profileBodyHeight, userXId, screenType}} + whiteRing={undefined} + /> <View style={styles.momentsContainer}> {userXId && moments.length === 0 && ( <View style={styles.plusIconContainer}> diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 6b513f4e..d24e352e 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -1,6 +1,6 @@ import {ReactText} from 'react'; -import {BackgroundGradientType, ExploreSectionType} from './../types/'; -import {SCREEN_WIDTH, SCREEN_HEIGHT, isIPhoneX, normalize} from '../utils'; +import {isIPhoneX, normalize, SCREEN_HEIGHT, SCREEN_WIDTH} from '../utils'; +import {BackgroundGradientType} from './../types/'; export const CHIN_HEIGHT = 34; @@ -182,17 +182,6 @@ export const MOMENT_CATEGORY_BG_COLORS: string[] = [ '#4E7175', ]; -// order matters, this decides the order which it displays -export const EXPLORE_SECTION_TITLES: ExploreSectionType[] = [ - 'New to Tagg', - 'People You May Know', - 'Trending on Tagg', - "Brown '24", - "Brown '23", - "Brown '22", - "Brown '21", -]; - export const SP_WIDTH = 375; export const SP_HEIGHT = 812; diff --git a/src/services/ExploreService.ts b/src/services/ExploreService.ts index 07af91ad..44df8056 100644 --- a/src/services/ExploreService.ts +++ b/src/services/ExploreService.ts @@ -4,12 +4,7 @@ import { DISCOVER_ENDPOINT, SEARCH_BUTTONS_ENDPOPINT, } from '../constants'; -import {EMPTY_PROFILE_PREVIEW_LIST} from '../store/initialStates'; -import { - ExploreSectionType, - ProfilePreviewType, - SearchCategoryType, -} from '../types'; +import {ProfilePreviewType, SearchCategoryType} from '../types'; export const getAllTaggUsers = async (token: string) => { try { @@ -38,36 +33,6 @@ export const getAllTaggUsers = async (token: string) => { } }; -export const getAllExploreSections = async () => { - try { - const token = await AsyncStorage.getItem('token'); - const response = await fetch(DISCOVER_ENDPOINT, { - method: 'GET', - headers: { - Authorization: 'Token ' + token, - }, - }); - if (response.status !== 200) { - return EMPTY_PROFILE_PREVIEW_LIST; - } - const data = await response.json(); - // TODO (if we return to original explore format): get keys from backend API - const exploreSections: Record<ExploreSectionType, ProfilePreviewType[]> = { - 'New to Tagg': data.categories.new_to_tagg, - 'People You May Know': data.categories.people_you_may_know, - 'Trending on Tagg': data.categories.trending_on_tagg, - "Brown '21": data.categories.brown_21, - "Brown '22": data.categories.brown_22, - "Brown '23": data.categories.brown_23, - "Brown '24": data.categories.brown_24, - }; - - return exploreSections; - } catch (error) { - console.log('Unable to fetch explore data'); - } -}; - export const getDiscoverUsers = async (categoryName: string) => { try { const token = await AsyncStorage.getItem('token'); diff --git a/src/store/actions/taggUsers.ts b/src/store/actions/taggUsers.ts index 72ce848b..0cd94e92 100644 --- a/src/store/actions/taggUsers.ts +++ b/src/store/actions/taggUsers.ts @@ -1,5 +1,5 @@ import {Action, ThunkAction} from '@reduxjs/toolkit'; -import {getAllExploreSections, loadRecentlySearchedUsers} from '../../services'; +import {loadRecentlySearchedUsers} from '../../services'; import {taggUsersFetched} from '../reducers'; import {RootState} from '../rootReducer'; @@ -11,7 +11,6 @@ export const loadRecentlySearched = (): ThunkAction< > => async (dispatch) => { try { const recentSearches = await loadRecentlySearchedUsers(); - getAllExploreSections(); dispatch({ type: taggUsersFetched.type, payload: {recentSearches}, diff --git a/src/types/types.ts b/src/types/types.ts index 3a4491a3..9a40e4c0 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -134,15 +134,6 @@ export enum ScreenType { SuggestedPeople, } -export type ExploreSectionType = - | 'People You May Know' - | 'New to Tagg' - | 'Trending on Tagg' - | "Brown '21" - | "Brown '22" - | "Brown '23" - | "Brown '24"; - /** * Redux store to have a Record of ScreenType (Search, Profile, Home etc) mapped to * A Record of userIXd mapped to UserXType |