feat: disable button when comments have not been changed (#477)

This commit is contained in:
Suemor 2023-05-03 19:54:30 +08:00 committed by GitHub
parent 289316e27b
commit 20230d147a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -41,6 +41,8 @@ export const CommentInput: React.FC<{
},
})
const inputContent = form.watch("content").trim()
const handleSubmit = form.handleSubmit(async (values) => {
if (characterId && noteId) {
if (comment) {
@ -122,7 +124,9 @@ export const CommentInput: React.FC<{
type="submit"
isLoading={commentPage.isLoading || updateComment.isLoading}
isDisabled={
!!account?.character && form.watch("content").trim().length === 0
!!account?.character &&
(!inputContent ||
inputContent === comment?.metadata?.content?.content)
}
>
{t(