code review: refactor

This commit is contained in:
Sinclair Chen 2022-08-04 15:19:00 -07:00
parent 694120216a
commit 506cab6c82
2 changed files with 5 additions and 6 deletions

View File

@ -71,11 +71,10 @@ export function FeedAnswerCommentGroup(props: {
const scrollAndOpenReplyInput = useEvent( const scrollAndOpenReplyInput = useEvent(
(comment?: Comment, answer?: Answer) => { (comment?: Comment, answer?: Answer) => {
setReplyToUser( setReplyToUser(
comment ?? answer comment
? { ? { id: comment.userId, username: comment.userUsername }
id: comment?.userId ?? (answer as Answer).userId, : answer
username: comment?.userUsername ?? (answer as Answer).username, ? { id: answer.userId, username: answer.username }
}
: undefined : undefined
) )
setShowReply(true) setShowReply(true)

View File

@ -302,7 +302,7 @@ const GroupMessage = memo(function GroupMessage_(props: {
const first = comments[0] const first = comments[0]
const { id, userUsername, userName, userAvatarUrl, createdTime } = first const { id, userUsername, userName, userAvatarUrl, createdTime } = first
const isCreatorsComment = user && comments[0].userId === user.id const isCreatorsComment = user && first.userId === user.id
return ( return (
<Col <Col
ref={setRef} ref={setRef}