Skip to content

Commit 12644c8

Browse files
committed
feat: allow operation uploader to delete comments from others
1 parent cc3558e commit 12644c8

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/components/viewer/comment/CommentArea.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ const MainComment = ({
156156
comment: MainCommentInfo
157157
children?: ReactNode
158158
}) => {
159-
const { operationOwned } = useContext(CommentAreaContext)
160-
161159
return (
162160
<Card
163161
className={clsx(
@@ -168,7 +166,7 @@ const MainComment = ({
168166
<div>
169167
<CommentHeader comment={comment} />
170168
<CommentContent comment={comment} />
171-
<CommentActions comment={comment} operationOwned={operationOwned} />
169+
<CommentActions comment={comment} />
172170
</div>
173171
{children}
174172
</Card>
@@ -256,14 +254,13 @@ const CommentContent = ({
256254
const CommentActions = ({
257255
className,
258256
comment,
259-
operationOwned,
260257
}: {
261258
className?: string
262259
comment: CommentInfo
263-
operationOwned?: boolean
264260
}) => {
265261
const [{ userId }] = useAtom(authAtom)
266-
const { replyTo, setReplyTo, reload } = useContext(CommentAreaContext)
262+
const { operationOwned, replyTo, setReplyTo, reload } =
263+
useContext(CommentAreaContext)
267264

268265
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false)
269266
const [pending, setPending] = useState(false)
@@ -301,14 +298,14 @@ const CommentActions = ({
301298
small
302299
className="!font-normal !text-[13px]"
303300
active={replyTo === comment}
304-
onClick={() => setReplyTo(replyTo !== comment ? comment : undefined)}
301+
onClick={() => setReplyTo(replyTo === comment ? undefined : comment)}
305302
>
306303
回复
307304
</Button>
308305
{operationOwned && isMainComment(comment) && (
309306
<CommentTopButton comment={comment} />
310307
)}
311-
{userId === comment.uploaderId && (
308+
{(operationOwned || userId === comment.uploaderId) && (
312309
<Button
313310
minimal
314311
small

0 commit comments

Comments
 (0)