@@ -20,6 +20,8 @@ import {
20
20
useComments ,
21
21
} from '../../../apis/comment'
22
22
import {
23
+ MAX_COMMENT_LENGTH ,
24
+ AUTHOR_MAX_COMMENT_LENGTH ,
23
25
CommentInfo ,
24
26
CommentRating ,
25
27
MainCommentInfo ,
@@ -62,11 +64,10 @@ export const CommentArea = withSuspensable(function ViewerComments({
62
64
63
65
const auth = useAtomValue ( authAtom )
64
66
const operation = useOperation ( { id : operationId } ) . data
65
- // FIXME: 用户名可以重名,这里会让重名用户都显示置顶按钮,需要等后端支持 operation.uploaderId 后再修复
66
- const operationOwned =
67
- ! ! operation ?. uploader &&
68
- ! ! auth . username &&
69
- operation . uploader === auth . username
67
+
68
+ const operationOwned = operation && auth . userId && operation . uploaderId === auth . userId
69
+
70
+ const maxLength = operationOwned ? AUTHOR_MAX_COMMENT_LENGTH : MAX_COMMENT_LENGTH
70
71
71
72
const [ replyTo , setReplyTo ] = useState < CommentInfo > ( )
72
73
@@ -94,7 +95,7 @@ export const CommentArea = withSuspensable(function ViewerComments({
94
95
return (
95
96
< CommentAreaContext . Provider value = { contextValue } >
96
97
< div >
97
- < CommentForm primary className = "mb-6" />
98
+ < CommentForm primary className = "mb-6" maxLength = { maxLength } />
98
99
{ comments ?. map ( ( comment ) => (
99
100
< MainComment
100
101
key = { comment . commentId }
@@ -110,8 +111,8 @@ export const CommentArea = withSuspensable(function ViewerComments({
110
111
sub . fromCommentId === comment . commentId
111
112
? undefined
112
113
: find ( comment . subCommentsInfos , {
113
- commentId : sub . fromCommentId ,
114
- } )
114
+ commentId : sub . fromCommentId ,
115
+ } )
115
116
}
116
117
/>
117
118
) ) }
@@ -261,6 +262,7 @@ const CommentActions = ({
261
262
const [ { userId } ] = useAtom ( authAtom )
262
263
const { operationOwned, replyTo, setReplyTo, reload } =
263
264
useContext ( CommentAreaContext )
265
+ const maxLength = operationOwned ? AUTHOR_MAX_COMMENT_LENGTH : MAX_COMMENT_LENGTH
264
266
265
267
const [ deleteDialogOpen , setDeleteDialogOpen ] = useState ( false )
266
268
const [ pending , setPending ] = useState ( false )
@@ -331,7 +333,7 @@ const CommentActions = ({
331
333
</ p >
332
334
</ Alert >
333
335
</ div >
334
- { replyTo === comment && < CommentForm inputAutoFocus className = "mt-4" /> }
336
+ { replyTo === comment && < CommentForm inputAutoFocus className = "mt-4" maxLength = { maxLength } /> }
335
337
</ div >
336
338
)
337
339
}
0 commit comments