From 0fd892ad288f2e1eaaa4fdf5e1fd6f15dbd45860 Mon Sep 17 00:00:00 2001 From: Ashm Walia <40498934+ashmgarv@users.noreply.github.com> Date: Fri, 4 Dec 2020 08:50:24 -0800 Subject: [TMA - 398 AND TMA-430] Replace Providers with Redux Store (#125) * First * WIP * Thunk * Some more comments * sc * recent searches and follounfollow * Edit profile dummy * Block / unblock and some cleanup * Replace auth provider * Sc * Delete AP after rebase * Discover users * Cleanup * More cleanup * Replace profile provider * Fixed build failure * Fixed a bug reported * Prevent app crash when backend server is down --- src/components/moments/Moment.tsx | 20 ++++++++++++++------ src/components/moments/MomentTile.tsx | 23 +++++++++++++---------- 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src/components/moments') diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index 9e138ef3..0c8febcf 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -10,15 +10,21 @@ import {TAGG_TEXT_LIGHT_BLUE} from '../../constants'; import {SCREEN_WIDTH} from '../../utils'; import ImagePicker from 'react-native-image-crop-picker'; import MomentTile from './MomentTile'; -import {MomentType} from 'src/types'; +import {MomentType, ScreenType} from 'src/types'; interface MomentProps { title: string; images: MomentType[] | undefined; - isProfileView: boolean; + userXId: string; + screenType: ScreenType; } -const Moment: React.FC = ({title, images, isProfileView}) => { +const Moment: React.FC = ({ + title, + images, + userXId, + screenType, +}) => { const navigation = useNavigation(); const navigateToImagePicker = () => { @@ -32,6 +38,7 @@ const Moment: React.FC = ({title, images, isProfileView}) => { .then((picture) => { if ('path' in picture) { navigation.navigate('CaptionScreen', { + screenType, title: title, image: picture, }); @@ -45,7 +52,7 @@ const Moment: React.FC = ({title, images, isProfileView}) => { {title} - {!isProfileView ? ( + {!userXId ? ( = ({title, images, isProfileView}) => { ))} - {(images === undefined || images.length === 0) && !isProfileView && ( + {(images === undefined || images.length === 0) && !userXId && ( navigateToImagePicker()}> diff --git a/src/components/moments/MomentTile.tsx b/src/components/moments/MomentTile.tsx index 787957e0..cc24c531 100644 --- a/src/components/moments/MomentTile.tsx +++ b/src/components/moments/MomentTile.tsx @@ -1,26 +1,29 @@ import {useNavigation} from '@react-navigation/native'; import React from 'react'; import {StyleSheet, View, Image, TouchableOpacity} from 'react-native'; -import {MomentType} from 'src/types'; -import {ProfileContext} from '../../routes'; +import {MomentType, ScreenType} from 'src/types'; interface MomentTileProps { moment: MomentType; - isProfileView: boolean; + userXId: string; + screenType: ScreenType; } -const MomentTile: React.FC = ({moment, isProfileView}) => { +const MomentTile: React.FC = ({ + moment, + userXId, + screenType, +}) => { const navigation = useNavigation(); - //Username is needed by the IndividualMoment screen - const { - user: {username}, - } = React.useContext(ProfileContext); - const {path_hash} = moment; return ( { - navigation.push('IndividualMoment', {moment, isProfileView, username}); + navigation.push('IndividualMoment', { + moment, + screenType, + userXId, + }); }}> -- cgit v1.2.3-70-g09d2