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/screens/profile/MomentCommentsScreen.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/screens/profile/MomentCommentsScreen.tsx') diff --git a/src/screens/profile/MomentCommentsScreen.tsx b/src/screens/profile/MomentCommentsScreen.tsx index 7a0bfa66..34f85c28 100644 --- a/src/screens/profile/MomentCommentsScreen.tsx +++ b/src/screens/profile/MomentCommentsScreen.tsx @@ -9,8 +9,9 @@ import {Button} from 'react-native-elements'; import {AddComment} from '../../components/'; import {useEffect} from 'react'; import AsyncStorage from '@react-native-community/async-storage'; -import {AuthContext} from '../../routes/authentication'; import {getMomentComments} from '../..//services'; +import {useDispatch} from 'react-redux'; +import {logout} from '../../store/actions'; /** * Comments Screen for an image uploaded @@ -29,16 +30,16 @@ interface MomentCommentsScreenProps { const MomentCommentsScreen: React.FC = ({route}) => { const navigation = useNavigation(); - const {isProfileView, moment_id} = route.params; + const {moment_id, screenType} = route.params; const [commentsList, setCommentsList] = React.useState([]); const [newCommentsAvailable, setNewCommentsAvailable] = React.useState(true); - const {logout} = React.useContext(AuthContext); + const dispatch = useDispatch(); useEffect(() => { const loadComments = async () => { const token = await AsyncStorage.getItem('token'); if (!token) { - logout(); + dispatch(logout()); return; } getMomentComments(moment_id, setCommentsList, token); @@ -70,7 +71,11 @@ const MomentCommentsScreen: React.FC = ({route}) => { contentContainerStyle={styles.modalScrollViewContent}> {commentsList && commentsList.map((comment: CommentType) => ( - + ))}