Skip to content

Commit 460fcdc

Browse files
committed
refactor: fix type error
1 parent 55bdaa5 commit 460fcdc

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/components/viewer/comment/CommentArea.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import {
2020
useComments,
2121
} from '../../../apis/comment'
2222
import {
23-
MAX_COMMENT_LENGTH,
2423
AUTHOR_MAX_COMMENT_LENGTH,
2524
CommentInfo,
2625
CommentRating,
26+
MAX_COMMENT_LENGTH,
2727
MainCommentInfo,
2828
SubCommentInfo,
2929
isMainComment,
@@ -66,9 +66,15 @@ export const CommentArea = withSuspensable(function ViewerComments({
6666
const auth = useAtomValue(authAtom)
6767
const operation = useOperation({ id: operationId }).data
6868

69-
const operationOwned = operation && auth.userId && operation.uploaderId === auth.userId
69+
const operationOwned = !!(
70+
operation &&
71+
auth.userId &&
72+
operation.uploaderId === auth.userId
73+
)
7074

71-
const maxLength = operationOwned ? AUTHOR_MAX_COMMENT_LENGTH : MAX_COMMENT_LENGTH
75+
const maxLength = operationOwned
76+
? AUTHOR_MAX_COMMENT_LENGTH
77+
: MAX_COMMENT_LENGTH
7278

7379
const [replyTo, setReplyTo] = useState<CommentInfo>()
7480

@@ -112,8 +118,8 @@ export const CommentArea = withSuspensable(function ViewerComments({
112118
sub.fromCommentId === comment.commentId
113119
? undefined
114120
: find(comment.subCommentsInfos, {
115-
commentId: sub.fromCommentId,
116-
})
121+
commentId: sub.fromCommentId,
122+
})
117123
}
118124
/>
119125
))}
@@ -266,7 +272,9 @@ const CommentActions = ({
266272
const [{ userId }] = useAtom(authAtom)
267273
const { operationOwned, replyTo, setReplyTo, reload } =
268274
useContext(CommentAreaContext)
269-
const maxLength = operationOwned ? AUTHOR_MAX_COMMENT_LENGTH : MAX_COMMENT_LENGTH
275+
const maxLength = operationOwned
276+
? AUTHOR_MAX_COMMENT_LENGTH
277+
: MAX_COMMENT_LENGTH
270278

271279
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
272280
const [pending, setPending] = useState(false)
@@ -337,7 +345,9 @@ const CommentActions = ({
337345
</p>
338346
</Alert>
339347
</div>
340-
{replyTo === comment && <CommentForm inputAutoFocus className="mt-4" maxLength={maxLength} />}
348+
{replyTo === comment && (
349+
<CommentForm inputAutoFocus className="mt-4" maxLength={maxLength} />
350+
)}
341351
</div>
342352
)
343353
}

0 commit comments

Comments
 (0)