diff options
author | Ivan Chen <ivan@thetaggid.com> | 2021-02-05 13:29:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 13:29:46 -0500 |
commit | 07a2e3841d49b3fb278f17676c1007b003f58b9e (patch) | |
tree | 0e8c9ebdb03ac2e64172f9a593288f08e2a8108b /src/components/comments/AddComment.tsx | |
parent | 454f5dec8cbf2065ba615fa83183cbde44ffee21 (diff) | |
parent | c3cd8f95c6534fb5eb78af299ef424c50aefd85a (diff) |
Merge branch 'master' into tma590-friendslist-buttons
Diffstat (limited to 'src/components/comments/AddComment.tsx')
-rw-r--r-- | src/components/comments/AddComment.tsx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/components/comments/AddComment.tsx b/src/components/comments/AddComment.tsx index 44f49748..56011f05 100644 --- a/src/components/comments/AddComment.tsx +++ b/src/components/comments/AddComment.tsx @@ -8,10 +8,11 @@ import { View, } from 'react-native'; import {TextInput, TouchableOpacity} from 'react-native-gesture-handler'; -import {useSelector} from 'react-redux'; +import {useDispatch, useSelector} from 'react-redux'; import UpArrowIcon from '../../assets/icons/up_arrow.svg'; import {TAGG_LIGHT_BLUE} from '../../constants'; import {postComment} from '../../services'; +import {updateReplyPosted} from '../../store/actions'; import {RootState} from '../../store/rootreducer'; import {SCREEN_HEIGHT, SCREEN_WIDTH} from '../../utils'; @@ -38,6 +39,7 @@ const AddComment: React.FC<AddCommentProps> = ({ const [keyboardVisible, setKeyboardVisible] = React.useState(false); const {avatar} = useSelector((state: RootState) => state.user); + const dispatch = useDispatch(); const addComment = async () => { const trimmed = comment.trim(); @@ -52,6 +54,18 @@ const AddComment: React.FC<AddCommentProps> = ({ if (postedComment) { setComment(''); + + //Set new reply posted object + //This helps us show the latest reply on top + //Data set is kind of stale but it works + if (isCommentInFocus) { + dispatch( + updateReplyPosted({ + comment_id: postedComment.comment_id, + parent_comment: {comment_id: objectId}, + }), + ); + } setNewCommentsAvailable(true); } }; |