From 770dcf385fa99fbb93c4ae89a51b09fd96d23bf9 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 10 Jun 2021 17:23:47 -0400 Subject: Add util function, Add logic for updating comment preview --- src/components/comments/AddComment.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/components/comments/AddComment.tsx') diff --git a/src/components/comments/AddComment.tsx b/src/components/comments/AddComment.tsx index 12fd7e4d..18b9c24e 100644 --- a/src/components/comments/AddComment.tsx +++ b/src/components/comments/AddComment.tsx @@ -24,12 +24,14 @@ import {MentionInputControlled} from './MentionInputControlled'; export interface AddCommentProps { momentId: string; placeholderText: string; + callback?: (message: string) => void; theme?: 'dark' | 'white'; } const AddComment: React.FC = ({ momentId, placeholderText, + callback = (msg) => null, theme = 'white', }) => { const {setShouldUpdateAllComments = () => null, commentTapped} = @@ -55,13 +57,15 @@ const AddComment: React.FC = ({ if (trimmed === '') { return; } + const message = inReplyToMention + trimmed; const postedComment = await postComment( - inReplyToMention + trimmed, + message, objectId, isReplyingToComment || isReplyingToReply, ); if (postedComment) { + callback(message); setComment(''); setInReplyToMention(''); -- cgit v1.2.3-70-g09d2