aboutsummaryrefslogtreecommitdiff
path: root/src/components/comments/AddComment.tsx
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2021-01-31 13:16:41 -0800
committerGitHub <noreply@github.com>2021-01-31 13:16:41 -0800
commitb7509400433169e698450e4a7667d268439dcf41 (patch)
tree92fcfb0f91d1498f8a36762a1ee650f17dbb3af8 /src/components/comments/AddComment.tsx
parentce18efb5318c230944167d42bbde827aaca4ee4a (diff)
parent60d281814c60a471598746b4dad8f3d18be0931c (diff)
Merge pull request #209 from ashmgarv/tma-612-611-redesign-comments
[TMA 612/611] Frontend
Diffstat (limited to 'src/components/comments/AddComment.tsx')
-rw-r--r--src/components/comments/AddComment.tsx16
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);
}
};