aboutsummaryrefslogtreecommitdiff
path: root/src/routes/profile
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2020-12-04 08:50:24 -0800
committerGitHub <noreply@github.com>2020-12-04 11:50:24 -0500
commit0fd892ad288f2e1eaaa4fdf5e1fd6f15dbd45860 (patch)
treed7d53d94c6c4026ac9b325508ebce4706d412ac4 /src/routes/profile
parentf620102190629e0b6f180d3ce056d850b1db5aaa (diff)
[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
Diffstat (limited to 'src/routes/profile')
-rw-r--r--src/routes/profile/Profile.tsx38
-rw-r--r--src/routes/profile/ProfileStack.tsx36
2 files changed, 45 insertions, 29 deletions
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<ProfileStackParams, 'Profile'>;
@@ -31,7 +31,12 @@ interface ProfileStackProps {
}
const Profile: React.FC<ProfileStackProps> = ({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 (
<ProfileStack.Navigator
screenOptions={{
@@ -56,15 +61,21 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
}),
}}
mode="modal"
- initialRouteName={!isProfileView ? 'Profile' : 'Search'}>
+ initialRouteName={isProfileStack ? 'Profile' : 'Search'}>
<ProfileStack.Screen
name="Profile"
component={ProfileScreen}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{
+ screenType,
+ }}
/>
- {isProfileView ? (
- <ProfileStack.Screen name="Search" component={SearchScreen} />
+ {!isProfileStack ? (
+ <ProfileStack.Screen
+ name="Search"
+ component={SearchScreen}
+ initialParams={{screenType}}
+ />
) : (
<React.Fragment />
)}
@@ -77,8 +88,9 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
headerBackTitleVisible: false,
headerTintColor: 'white',
}}
+ initialParams={{screenType}}
/>
- {!isProfileView ? (
+ {isProfileStack ? (
<ProfileStack.Screen name="CaptionScreen" component={CaptionScreen} />
) : (
<React.Fragment />
@@ -87,18 +99,18 @@ const Profile: React.FC<ProfileStackProps> = ({route}) => {
name="IndividualMoment"
component={IndividualMoment}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="MomentCommentsScreen"
component={MomentCommentsScreen}
options={{headerShown: false}}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="FollowersListScreen"
component={FollowersListScreen}
- initialParams={{isProfileView: isProfileView}}
+ initialParams={{screenType}}
/>
<ProfileStack.Screen
name="EditProfile"
diff --git a/src/routes/profile/ProfileStack.tsx b/src/routes/profile/ProfileStack.tsx
index 5590f78a..e7db9f37 100644
--- a/src/routes/profile/ProfileStack.tsx
+++ b/src/routes/profile/ProfileStack.tsx
@@ -1,41 +1,45 @@
+/**
+ * Note the name userXId here, it refers to the id of the user being visited
+ */
import {createStackNavigator} from '@react-navigation/stack';
-import {MomentType, ProfilePreviewType, SocialAccountType} from '../../types';
+import {MomentType, ScreenType} from '../../types';
export type ProfileStackParams = {
- Search: undefined;
+ Search: {
+ screenType: ScreenType;
+ };
Profile: {
- isProfileView: boolean;
- username: string;
- userId: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
SocialMediaTaggs: {
socialMediaType: string;
- socialMediaHandle: string;
- isProfileView: boolean;
- name: string;
- accountData: SocialAccountType;
- avatar: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
CaptionScreen: {
title: string;
image: object;
+ screenType: ScreenType;
};
IndividualMoment: {
moment: MomentType;
- isProfileView: boolean;
- username: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
MomentCommentsScreen: {
- isProfileView: boolean;
moment_id: string;
+ userXId: string | undefined;
+ screenType: ScreenType;
};
FollowersListScreen: {
isFollowers: boolean;
- list: ProfilePreviewType[];
+ userXId: string | undefined;
+ screenType: ScreenType;
};
EditProfile: {
- userId: boolean;
- username: ProfilePreviewType[];
+ userId: string;
+ username: string;
};
};