aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-06-11 15:44:42 -0400
committerIvan Chen <ivan@tagg.id>2021-06-11 15:44:42 -0400
commit23c1a0861a6370241fcb73652af99272baff10ae (patch)
tree01327e1ce02d0292bc7757c9b6c902912945b2e1
parente4dd6cf05a631197be4d192901d532e8625900bb (diff)
Update comment count
-rw-r--r--src/components/moments/MomentPostContent.tsx12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx
index 89f2a281..f1ab5db4 100644
--- a/src/components/moments/MomentPostContent.tsx
+++ b/src/components/moments/MomentPostContent.tsx
@@ -47,6 +47,9 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
const [fadeValue, setFadeValue] = useState<Animated.Value<number>>(
new Animated.Value(0),
);
+ const [commentCount, setCommentCount] = useState<number>(
+ moment.comments_count,
+ );
const [commentPreview, setCommentPreview] =
useState<MomentCommentPreviewType | null>(moment.comment_preview);
const {keyboardVisible, scrollTo} = useContext(MomentContext);
@@ -121,7 +124,7 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
})}
<MomentCommentPreview
momentId={moment.moment_id}
- commentsCount={moment.comments_count}
+ commentsCount={commentCount}
commentPreview={commentPreview}
screenType={screenType}
/>
@@ -130,12 +133,13 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({
<AddComment
placeholderText={'Add a comment here!'}
momentId={moment.moment_id}
- callback={(message) =>
+ callback={(message) => {
setCommentPreview({
commenter: getLoggedInUserAsProfilePreview(state),
comment: message,
- })
- }
+ });
+ setCommentCount(commentCount + 1);
+ }}
onFocus={() => {
setHideText(true);
scrollTo(index);