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/App.tsx | 11 +-
src/components/comments/AddComment.tsx | 13 +-
src/components/comments/CommentTile.tsx | 9 +-
src/components/comments/CommentsCount.tsx | 9 +-
src/components/common/AvatarTitle.tsx | 5 +-
src/components/common/TaggLoadingIndicator.tsx | 27 +++
src/components/common/index.ts | 2 +-
src/components/common/post/Post.tsx | 28 ---
src/components/common/post/PostHeader.tsx | 78 ------
src/components/common/post/index.ts | 1 -
src/components/moments/Moment.tsx | 20 +-
src/components/moments/MomentTile.tsx | 23 +-
src/components/profile/Avatar.tsx | 18 +-
src/components/profile/Content.tsx | 167 +++++++------
src/components/profile/Cover.tsx | 19 +-
src/components/profile/FollowCount.tsx | 34 ++-
src/components/profile/Followers.tsx | 10 +-
src/components/profile/MoreInfoDrawer.tsx | 6 +-
src/components/profile/ProfileBody.tsx | 23 +-
src/components/profile/ProfileHeader.tsx | 48 ++--
src/components/profile/ProfilePreview.tsx | 30 ++-
src/components/search/DiscoverUsers.tsx | 19 +-
src/components/search/RecentSearches.tsx | 13 +-
src/components/search/SearchResults.tsx | 14 +-
src/components/taggs/Tagg.tsx | 41 ++--
src/components/taggs/TaggsBar.tsx | 61 +++--
src/routes/Routes.tsx | 24 +-
src/routes/authentication/AuthProvider.tsx | 315 -------------------------
src/routes/authentication/index.ts | 2 -
src/routes/index.ts | 4 -
src/routes/profile/Profile.tsx | 38 ++-
src/routes/profile/ProfileStack.tsx | 36 +--
src/routes/tabs/NavigationBar.tsx | 5 +-
src/routes/viewProfile/ProfileProvider.tsx | 207 ----------------
src/routes/viewProfile/index.ts | 2 -
src/screens/onboarding/Checkpoint.tsx | 1 -
src/screens/onboarding/Login.tsx | 15 +-
src/screens/onboarding/SocialMedia.tsx | 14 +-
src/screens/profile/CaptionScreen.tsx | 26 +-
src/screens/profile/EditProfile.tsx | 13 +-
src/screens/profile/FollowersListScreen.tsx | 21 +-
src/screens/profile/IndividualMoment.tsx | 25 +-
src/screens/profile/MomentCommentsScreen.tsx | 15 +-
src/screens/profile/ProfileScreen.tsx | 74 +++---
src/screens/profile/SocialMediaTaggs.tsx | 100 +++++---
src/screens/search/SearchScreen.tsx | 37 ++-
src/services/BlockUserService.ts | 8 +-
src/services/ExploreServices.ts | 7 +-
src/services/MomentServices.ts | 31 ++-
src/services/UserFollowServices.ts | 18 +-
src/services/UserProfileService.ts | 60 +----
src/store/actions/index.ts | 7 +
src/store/actions/socials.ts | 38 +++
src/store/actions/taggUsers.ts | 24 ++
src/store/actions/user.ts | 52 ++++
src/store/actions/userBlock.ts | 48 ++++
src/store/actions/userFollow.ts | 57 +++++
src/store/actions/userMoments.ts | 22 ++
src/store/actions/userX.ts | 131 ++++++++++
src/store/configureStore.ts | 20 ++
src/store/initialStates.ts | 95 ++++++++
src/store/reducers/index.ts | 7 +
src/store/reducers/taggUsersReducer.ts | 16 ++
src/store/reducers/userBlockReducer.ts | 25 ++
src/store/reducers/userFollowReducer.ts | 27 +++
src/store/reducers/userMomentsReducer.ts | 15 ++
src/store/reducers/userReducer.ts | 36 +++
src/store/reducers/userSocialsReducer.ts | 21 ++
src/store/reducers/userXReducer.ts | 77 ++++++
src/store/rootReducer.ts | 30 +++
src/types/types.ts | 23 ++
src/utils/hooks.ts | 31 +++
src/utils/index.ts | 1 +
src/utils/users.ts | 97 ++++++++
74 files changed, 1612 insertions(+), 1115 deletions(-)
create mode 100644 src/components/common/TaggLoadingIndicator.tsx
delete mode 100644 src/components/common/post/Post.tsx
delete mode 100644 src/components/common/post/PostHeader.tsx
delete mode 100644 src/components/common/post/index.ts
delete mode 100644 src/routes/authentication/AuthProvider.tsx
delete mode 100644 src/routes/authentication/index.ts
delete mode 100644 src/routes/viewProfile/ProfileProvider.tsx
delete mode 100644 src/routes/viewProfile/index.ts
create mode 100644 src/store/actions/index.ts
create mode 100644 src/store/actions/socials.ts
create mode 100644 src/store/actions/taggUsers.ts
create mode 100644 src/store/actions/user.ts
create mode 100644 src/store/actions/userBlock.ts
create mode 100644 src/store/actions/userFollow.ts
create mode 100644 src/store/actions/userMoments.ts
create mode 100644 src/store/actions/userX.ts
create mode 100644 src/store/configureStore.ts
create mode 100644 src/store/initialStates.ts
create mode 100644 src/store/reducers/index.ts
create mode 100644 src/store/reducers/taggUsersReducer.ts
create mode 100644 src/store/reducers/userBlockReducer.ts
create mode 100644 src/store/reducers/userFollowReducer.ts
create mode 100644 src/store/reducers/userMomentsReducer.ts
create mode 100644 src/store/reducers/userReducer.ts
create mode 100644 src/store/reducers/userSocialsReducer.ts
create mode 100644 src/store/reducers/userXReducer.ts
create mode 100644 src/store/rootReducer.ts
create mode 100644 src/utils/hooks.ts
create mode 100644 src/utils/users.ts
(limited to 'src')
diff --git a/src/App.tsx b/src/App.tsx
index 2e6865fd..e1cd83cc 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,14 +1,19 @@
import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
-import Routes, {AuthProvider} from './routes';
+import Routes from './routes';
+import {Provider} from 'react-redux';
+import store from './store/configureStore';
const App = () => {
return (
-
+ /**
+ * This is the provider from the redux store, it acts as the root provider for our application
+ */
+
-
+
);
};
diff --git a/src/components/comments/AddComment.tsx b/src/components/comments/AddComment.tsx
index ac1628da..f8c0b6bc 100644
--- a/src/components/comments/AddComment.tsx
+++ b/src/components/comments/AddComment.tsx
@@ -7,9 +7,11 @@ import {
View,
} from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
-import {AuthContext} from '../../routes';
import {TaggBigInput} from '../onboarding';
import {postMomentComment} from '../../services';
+import {logout} from '../../store/actions';
+import {useSelector, useDispatch} from 'react-redux';
+import {RootState} from '../../store/rootreducer';
/**
* This file provides the add comment view for a user.
@@ -27,11 +29,12 @@ const AddComment: React.FC = ({
moment_id,
}) => {
const [comment, setComment] = React.useState('');
+
+ const dispatch = useDispatch();
const {
avatar,
- user: {userId, username},
- logout,
- } = React.useContext(AuthContext);
+ user: {userId},
+ } = useSelector((state: RootState) => state.user);
const handleCommentUpdate = (comment: string) => {
setComment(comment);
@@ -41,7 +44,7 @@ const AddComment: React.FC = ({
try {
const token = await AsyncStorage.getItem('token');
if (!token) {
- logout();
+ dispatch(logout());
return;
}
const postedComment = await postMomentComment(
diff --git a/src/components/comments/CommentTile.tsx b/src/components/comments/CommentTile.tsx
index bee590f5..da78a4dc 100644
--- a/src/components/comments/CommentTile.tsx
+++ b/src/components/comments/CommentTile.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import {Text, View} from 'react-native-animatable';
import {ProfilePreview} from '../profile';
-import {CommentType} from '../../types';
+import {CommentType, ScreenType} from '../../types';
import {StyleSheet} from 'react-native';
import {getTimePosted} from '../../utils';
import ClockIcon from '../../assets/icons/clock-icon-01.svg';
@@ -12,9 +12,13 @@ import ClockIcon from '../../assets/icons/clock-icon-01.svg';
interface CommentTileProps {
comment_object: CommentType;
+ screenType: ScreenType;
}
-const CommentTile: React.FC = ({comment_object}) => {
+const CommentTile: React.FC = ({
+ comment_object,
+ screenType,
+}) => {
const timePosted = getTimePosted(comment_object.date_time);
return (
@@ -26,6 +30,7 @@ const CommentTile: React.FC = ({comment_object}) => {
last_name: '',
}}
previewType={'Comment'}
+ screenType={screenType}
/>
{comment_object.comment}
diff --git a/src/components/comments/CommentsCount.tsx b/src/components/comments/CommentsCount.tsx
index a9d5b6d6..d210c39a 100644
--- a/src/components/comments/CommentsCount.tsx
+++ b/src/components/comments/CommentsCount.tsx
@@ -3,6 +3,7 @@ import {Text} from 'react-native-animatable';
import {StyleSheet, TouchableOpacity} from 'react-native';
import CommentIcon from '../../assets/icons/moment-comment-icon.svg';
import {useNavigation} from '@react-navigation/native';
+import {ScreenType} from '../../types';
/**
* Provides a view for the comment icon and the comment count.
@@ -11,20 +12,20 @@ import {useNavigation} from '@react-navigation/native';
type CommentsCountProps = {
comments_count: string;
- isProfileView: boolean;
moment_id: string;
+ screenType: ScreenType;
};
const CommentsCount: React.FC = ({
comments_count,
- isProfileView,
moment_id,
+ screenType,
}) => {
const navigation = useNavigation();
const navigateToCommentsScreen = async () => {
navigation.push('MomentCommentsScreen', {
- isProfileView: isProfileView,
- moment_id: moment_id,
+ moment_id,
+ screenType,
});
};
return (
diff --git a/src/components/common/AvatarTitle.tsx b/src/components/common/AvatarTitle.tsx
index 65ae7486..a38f46fa 100644
--- a/src/components/common/AvatarTitle.tsx
+++ b/src/components/common/AvatarTitle.tsx
@@ -2,12 +2,9 @@ import React from 'react';
import {Image, StyleSheet, View} from 'react-native';
import LinearGradient from 'react-native-linear-gradient';
import {TAGGS_GRADIENT} from '../../constants';
-import {AuthContext, ProfileContext} from '../../routes/';
-import {loadAvatar} from '../../services';
-import AsyncStorage from '@react-native-community/async-storage';
type AvatarTitleProps = {
- avatar: string;
+ avatar: string | null;
};
const AvatarTitle: React.FC = ({avatar}) => {
return (
diff --git a/src/components/common/TaggLoadingIndicator.tsx b/src/components/common/TaggLoadingIndicator.tsx
new file mode 100644
index 00000000..cfb99e80
--- /dev/null
+++ b/src/components/common/TaggLoadingIndicator.tsx
@@ -0,0 +1,27 @@
+import * as React from 'react';
+import {ActivityIndicator, StyleSheet, View} from 'react-native';
+
+type TaggLoadingIndicatorProps = {
+ color: string;
+};
+const TaggLoadingIndicator: React.FC = ({color}) => {
+ return (
+
+
+
+ );
+};
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ justifyContent: 'center',
+ },
+ horizontal: {
+ flexDirection: 'row',
+ justifyContent: 'space-around',
+ padding: 10,
+ },
+});
+
+export default TaggLoadingIndicator;
diff --git a/src/components/common/index.ts b/src/components/common/index.ts
index 0feeaab8..f6521497 100644
--- a/src/components/common/index.ts
+++ b/src/components/common/index.ts
@@ -15,4 +15,4 @@ export {default as ComingSoon} from './ComingSoon';
export {default as PostCarousel} from './PostCarousel';
export {default as TaggDatePicker} from './TaggDatePicker';
export {default as BottomDrawer} from './BottomDrawer';
-export * from './post';
+export {default as TaggLoadingTndicator} from './TaggLoadingIndicator';
diff --git a/src/components/common/post/Post.tsx b/src/components/common/post/Post.tsx
deleted file mode 100644
index 9fa167f2..00000000
--- a/src/components/common/post/Post.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import React from 'react';
-import {StyleSheet, View, Image} from 'react-native';
-import {PostType} from '../../../types';
-import PostHeader from './PostHeader';
-import {SCREEN_WIDTH} from '../../../utils';
-
-interface PostProps {
- post: PostType;
-}
-const Post: React.FC = ({post: {owner, social, data}}) => {
- return (
- <>
-
-
- {data && }
-
- >
- );
-};
-
-const styles = StyleSheet.create({
- image: {
- width: SCREEN_WIDTH,
- height: SCREEN_WIDTH,
- backgroundColor: '#eee',
- },
-});
-export default Post;
diff --git a/src/components/common/post/PostHeader.tsx b/src/components/common/post/PostHeader.tsx
deleted file mode 100644
index 0e9c708b..00000000
--- a/src/components/common/post/PostHeader.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import React from 'react';
-import {UserType, InstagramPostType} from '../../../types';
-import {View, StyleSheet, Image, Text} from 'react-native';
-import {AuthContext} from '../../../routes/authentication';
-import SocialIcon from '../SocialIcon';
-import moment from 'moment';
-
-const AVATAR_DIM = 35;
-interface PostHeaderProps {
- owner: UserType;
- post: InstagramPostType | undefined;
- social: string;
-}
-const PostHeader: React.FC = ({
- owner: {username},
- post,
- social,
-}) => {
- const {avatar} = React.useContext(AuthContext);
-
- return (
-
-
-
- {username}
- {post && }
-
- {post && (
-
- {moment(post.timestamp).format('LL')} at{' '}
- {moment(post.timestamp).format('LT')}
-
- )}
-
- );
-};
-
-const styles = StyleSheet.create({
- container: {
- flexDirection: 'column',
- justifyContent: 'space-between',
- padding: 10,
- backgroundColor: 'white',
- },
- topRow: {
- flexDirection: 'row',
- alignItems: 'center',
- },
- avatar: {
- width: AVATAR_DIM,
- height: AVATAR_DIM,
- borderRadius: AVATAR_DIM / 2,
- marginRight: 10,
- },
- icon: {
- width: AVATAR_DIM,
- height: AVATAR_DIM,
- borderRadius: AVATAR_DIM / 2,
- marginLeft: '55%',
- },
- username: {
- fontSize: 18,
- },
- timestamp: {
- color: '#6A757D',
- fontSize: 11,
- marginLeft: AVATAR_DIM + 10,
- },
-});
-
-export default PostHeader;
diff --git a/src/components/common/post/index.ts b/src/components/common/post/index.ts
deleted file mode 100644
index 358a59d5..00000000
--- a/src/components/common/post/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export {default as Post} from './Post';
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,
+ });
}}>
diff --git a/src/components/profile/Avatar.tsx b/src/components/profile/Avatar.tsx
index aca3bf4d..903d0d18 100644
--- a/src/components/profile/Avatar.tsx
+++ b/src/components/profile/Avatar.tsx
@@ -1,16 +1,20 @@
-import React from 'react';
+import React, {useContext} from 'react';
import {Image, StyleSheet} from 'react-native';
-import {AuthContext, ProfileContext} from '../../routes/';
+import {useSelector} from 'react-redux';
+import {RootState} from '../../store/rootreducer';
+import {ScreenType} from '../../types';
const PROFILE_DIM = 100;
interface AvatarProps {
style: object;
- isProfileView: boolean;
+ userXId: string;
+ screenType: ScreenType;
}
-const Avatar: React.FC = ({style, isProfileView}) => {
- const {avatar} = isProfileView
- ? React.useContext(ProfileContext)
- : React.useContext(AuthContext);
+const Avatar: React.FC = ({style, screenType, userXId}) => {
+ const {avatar} = userXId
+ ? useSelector((state: RootState) => state.userX[screenType][userXId])
+ : useSelector((state: RootState) => state.user);
+
return (
;
- isProfileView: boolean;
+ userXId: string;
+ screenType: ScreenType;
}
-const Content: React.FC = ({y, isProfileView}) => {
- const [profileBodyHeight, setProfileBodyHeight] = useState(0);
- const {user, moments, followers, following, updateFollowers} = isProfileView
- ? React.useContext(ProfileContext)
- : React.useContext(AuthContext);
-
- const {
- logout,
- user: loggedInUser,
- updateFollowers: updateLoggedInUserFollowers,
- blockedUsers,
- updateBlockedUsers,
- } = React.useContext(AuthContext);
+const Content: React.FC = ({y, userXId, screenType}) => {
+ const dispatch = useDispatch();
+
+ const {user = NO_USER, profile = NO_PROFILE} = userXId
+ ? useSelector((state: RootState) => state.userX[screenType][userXId])
+ : useSelector((state: RootState) => state.user);
+
+ const {followers = EMPTY_PROFILE_PREVIEW_LIST} = userXId
+ ? useSelector((state: RootState) => state.userX[screenType][userXId])
+ : useSelector((state: RootState) => state.follow);
+
+ const {moments = EMPTY_MOMENTS_LIST} = userXId
+ ? useSelector((state: RootState) => state.userX[screenType][userXId])
+ : useSelector((state: RootState) => state.moments);
+
+ const {blockedUsers = EMPTY_PROFILE_PREVIEW_LIST} = useSelector(
+ (state: RootState) => state.blocked,
+ );
+ const {user: loggedInUser = NO_USER} = useSelector(
+ (state: RootState) => state.user,
+ );
+ const state = useStore().getState();
/**
* States
@@ -38,8 +65,9 @@ const Content: React.FC = ({y, isProfileView}) => {
const [imagesMap, setImagesMap] = useState
)}
-
+
>
);
};
diff --git a/src/components/search/SearchResults.tsx b/src/components/search/SearchResults.tsx
index 2d5c9db8..001c7968 100644
--- a/src/components/search/SearchResults.tsx
+++ b/src/components/search/SearchResults.tsx
@@ -1,20 +1,26 @@
import React from 'react';
-import {ProfilePreviewType, PreviewType} from '../../types';
+import {ProfilePreviewType, PreviewType, ScreenType} from '../../types';
import ProfilePreview from '../profile/ProfilePreview';
import {StyleSheet, View} from 'react-native';
interface SearchResultsProps {
results: Array;
previewType: PreviewType;
+ screenType: ScreenType;
}
-const SearchResults: React.FC = (props) => {
+const SearchResults: React.FC = ({
+ results,
+ previewType,
+ screenType,
+}) => {
return (
- {props.results.map((profilePreview) => (
+ {results.map((profilePreview) => (
))}
diff --git a/src/components/taggs/Tagg.tsx b/src/components/taggs/Tagg.tsx
index 9f8fafd1..086b3c87 100644
--- a/src/components/taggs/Tagg.tsx
+++ b/src/components/taggs/Tagg.tsx
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
-import React, {Fragment, useContext, useState} from 'react';
+import React, {Fragment, useContext, useEffect, useState} from 'react';
import {Alert, Linking, StyleSheet, TouchableOpacity, View} from 'react-native';
import PurpleRingPlus from '../../assets/icons/purple_ring+.svg';
import PurpleRing from '../../assets/icons/purple_ring.svg';
@@ -17,36 +17,35 @@ import {
registerNonIntegratedSocialLink,
} from '../../services';
import {SmallSocialIcon, SocialIcon, SocialLinkModal} from '../common';
-import {AuthContext, ProfileContext} from '../../routes';
+import {useSelector} from 'react-redux';
+import {RootState} from '../../store/rootreducer';
+import {ScreenType} from '../../types';
interface TaggProps {
social: string;
- isProfileView: boolean;
isLinked: boolean;
isIntegrated: boolean;
setTaggsNeedUpdate: (_: boolean) => void;
- setSocialDataNeedUpdate: (_: string[]) => void;
- userId: string;
+ setSocialDataNeedUpdate: (_: string) => void;
+ userXId: string;
+ screenType: ScreenType;
}
const Tagg: React.FC = ({
social,
- isProfileView,
isLinked,
isIntegrated,
setTaggsNeedUpdate,
setSocialDataNeedUpdate,
- userId,
+ userXId,
+ screenType,
}) => {
const navigation = useNavigation();
const [modalVisible, setModalVisible] = useState(false);
- const youMayPass = isLinked || isProfileView;
- const {
- profile: {name},
- socialAccounts,
- avatar,
- } = isProfileView ? useContext(ProfileContext) : useContext(AuthContext);
-
+ const youMayPass = isLinked || userXId;
+ const {user} = userXId
+ ? useSelector((state: RootState) => state.userX[screenType][userXId])
+ : useSelector((state: RootState) => state.user);
/*
case isProfileView:
case linked:
@@ -62,7 +61,7 @@ const Tagg: React.FC = ({
show auth browser
case !integrated_social:
show modal
- Tagg's "Tagg" will use the Ring instead of PurpleRing
+ Tagg's "Tagg" will use the Ring instead of PurpleRing
*/
const modalOrAuthBrowserOrPass = async () => {
@@ -70,14 +69,10 @@ const Tagg: React.FC = ({
if (INTEGRATED_SOCIAL_LIST.indexOf(social) !== -1) {
navigation.push('SocialMediaTaggs', {
socialMediaType: social,
- isProfileView: isProfileView,
- userId: userId,
- name: name,
- accountData: socialAccounts[social],
- avatar: avatar,
+ userXId,
});
} else {
- getNonIntegratedURL(social, userId).then((socialURL) => {
+ getNonIntegratedURL(social, user.userId).then((socialURL) => {
if (socialURL) {
Linking.openURL(socialURL);
} else {
@@ -89,7 +84,7 @@ const Tagg: React.FC = ({
if (isIntegrated) {
handlePressForAuthBrowser(social).then((success) => {
setTaggsNeedUpdate(success);
- setSocialDataNeedUpdate(success ? [social] : []);
+ if (success) setSocialDataNeedUpdate(social);
});
} else {
setModalVisible(true);
@@ -127,7 +122,7 @@ const Tagg: React.FC = ({
return (
<>
- {isProfileView && !isLinked ? (
+ {userXId && !isLinked ? (
) : (
<>
diff --git a/src/components/taggs/TaggsBar.tsx b/src/components/taggs/TaggsBar.tsx
index aac68e99..12e4b93a 100644
--- a/src/components/taggs/TaggsBar.tsx
+++ b/src/components/taggs/TaggsBar.tsx
@@ -1,35 +1,53 @@
-// @refresh react
-import React, {useEffect, useState} from 'react';
+import React, {useEffect, useState, useContext} from 'react';
import {StyleSheet} from 'react-native';
import Animated from 'react-native-reanimated';
+import {useDispatch, useSelector} from 'react-redux';
import {
INTEGRATED_SOCIAL_LIST,
PROFILE_CUTOUT_BOTTOM_Y,
SOCIAL_LIST,
} from '../../constants';
-import {AuthContext, ProfileContext} from '../../routes';
import {getLinkedSocials} from '../../services';
import {StatusBarHeight} from '../../utils';
import Tagg from './Tagg';
+import {RootState} from '../../store/rootReducer';
+import {ScreenType} from '../../types';
+import {loadIndividualSocial} from '../../store/actions';
const {View, ScrollView, interpolate, Extrapolate} = Animated;
interface TaggsBarProps {
y: Animated.Value;
profileBodyHeight: number;
- isProfileView: boolean;
+ userXId: string;
+ screenType: ScreenType;
}
const TaggsBar: React.FC = ({
y,
profileBodyHeight,
- isProfileView,
+ userXId,
+ screenType,
}) => {
let [taggs, setTaggs] = useState