diff --git a/ui/component/commentCreate/view.jsx b/ui/component/commentCreate/view.jsx index c68bbc4b8..6ebc585e0 100644 --- a/ui/component/commentCreate/view.jsx +++ b/ui/component/commentCreate/view.jsx @@ -35,7 +35,7 @@ type Props = { toast: (string) => void, claimIsMine: boolean, sendTip: ({}, (any) => void, (any) => void) => void, - setjustCommented: (boolean) => void, + justCommented: Array, }; export function CommentCreate(props: Props) { @@ -54,7 +54,7 @@ export function CommentCreate(props: Props) { toast, claimIsMine, sendTip, - setjustCommented, + justCommented, } = props; const buttonref: ElementRef = React.useRef(); const { @@ -153,7 +153,7 @@ export function CommentCreate(props: Props) { setLastCommentTime(Date.now()); setIsReviewingSupportComment(false); setIsSupportComment(false); - setjustCommented(true); + justCommented.push(res.comment_id); if (onDoneReplying) { onDoneReplying(); diff --git a/ui/component/commentsList/view.jsx b/ui/component/commentsList/view.jsx index 7d45c5c90..af003a5ce 100644 --- a/ui/component/commentsList/view.jsx +++ b/ui/component/commentsList/view.jsx @@ -58,7 +58,7 @@ function CommentList(props: Props) { const [readyToDisplayComments, setReadyToDisplayComments] = React.useState( Boolean(reactionsById) || !ENABLE_COMMENT_REACTIONS ); - const [justCommented, setjustCommented] = React.useState(false); + const [justCommented] = React.useState([]); const linkedCommentId = linkedComment && linkedComment.comment_id; const hasNoComments = !totalComments; const moreBelow = totalComments - end > 0; @@ -210,7 +210,7 @@ function CommentList(props: Props) { } actions={ <> - + {!isFetchingComments && hasNoComments && ( diff --git a/ui/util/comments.js b/ui/util/comments.js index 246bd5583..74cabd8af 100644 --- a/ui/util/comments.js +++ b/ui/util/comments.js @@ -9,8 +9,8 @@ type SortProps = { comments: ?Array, reactionsById: {}, sort: string, - isMyComment: string => boolean, - justCommented: boolean, + isMyComment: (string) => boolean, + justCommented: Array, }; export function sortComments(sortProps: SortProps): Array { @@ -29,12 +29,12 @@ export function sortComments(sortProps: SortProps): Array { const aIsMine = isMyComment(a.channel_id); const bIsMine = isMyComment(b.channel_id); - const aIsMyRecent = a.comment_id === comments[0].comment_id; - const bIsMyRecent = b.comment_id === comments[0].comment_id; + const aIsMyRecent = justCommented.includes(a.comment_id); + const bIsMyRecent = justCommented.includes(b.comment_id); - if (aIsMine && justCommented && aIsMyRecent) { + if (aIsMine && justCommented.length && aIsMyRecent) { return -1; - } else if (bIsMine && justCommented && bIsMyRecent) { + } else if (bIsMine && justCommented.length && bIsMyRecent) { return 1; }