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/routes/profile/Profile.tsx | 38 ++++++++++++++++++++++++------------- src/routes/profile/ProfileStack.tsx | 36 +++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 29 deletions(-) (limited to 'src/routes/profile') diff --git a/src/routes/profile/Profile.tsx b/src/routes/profile/Profile.tsx index b6672c85..f47d25c4 100644 --- a/src/routes/profile/Profile.tsx +++ b/src/routes/profile/Profile.tsx @@ -11,17 +11,17 @@ import { } from '../../screens'; import {ProfileStack, ProfileStackParams} from './ProfileStack'; import {RouteProp} from '@react-navigation/native'; +import {ScreenType} from '../../types'; /** - * What will be the First Screen of the stack depends on value of isProfileView (Search if its true else Profile) * Trying to explain the purpose of each route on the stack (ACTUALLY A STACK) - * Profile : To display the logged in user's profile when isProfileView is false, else displays profile of any user the logged in user wants to view. - * When you click on the profile icon after looking at a user's profile, the stack is reset and you come back to the top of the stack (First screen : Profile in this case) - * Search : To display the search screen. Search for a user on this screen, click on a result tile and navigate to the same (isProfileView = true). + * Profile : To display the logged in user's profile when the userXId passed in to it is (undefined | null | empty string) else displays profile of the user being visited. + * Search : To display the search screen. Search for a user on this screen, click on a result tile and navigate to the same. * When you click on the search icon after looking at a user's profile, the stack gets reset and you come back to the top of the stack (First screen : Search in this case) * SocialMediaTaggs : To display user data for any social media account set up by the user. * IndividualMoment : To display individual images uploaded by the user (Navigate to comments from this screen, click on a commenter's profile pic / username, look at a user's profile. Click on the profile icon again to come back to your own profile). * MomentCommentsScreen : Displays comments posted by users on an image uploaded by the user. + * EditProfile : To edit logged in user's information. */ type ProfileStackRouteProps = RouteProp; @@ -31,7 +31,12 @@ interface ProfileStackProps { } const Profile: React.FC = ({route}) => { - const {isProfileView} = route.params; + const {screenType} = route.params; + + /** + * This parameter isProfileStack acts as a switch between Search and Profile Stacks + */ + const isProfileStack = screenType === ScreenType.Profile; return ( = ({route}) => { }), }} mode="modal" - initialRouteName={!isProfileView ? 'Profile' : 'Search'}> + initialRouteName={isProfileStack ? 'Profile' : 'Search'}> - {isProfileView ? ( - + {!isProfileStack ? ( + ) : ( )} @@ -77,8 +88,9 @@ const Profile: React.FC = ({route}) => { headerBackTitleVisible: false, headerTintColor: 'white', }} + initialParams={{screenType}} /> - {!isProfileView ? ( + {isProfileStack ? ( ) : ( @@ -87,18 +99,18 @@ const Profile: React.FC = ({route}) => { name="IndividualMoment" component={IndividualMoment} options={{headerShown: false}} - initialParams={{isProfileView: isProfileView}} + initialParams={{screenType}} />