@@ -127,6 +127,19 @@ type ReplyThread = {
127127} ;
128128
129129type CommentSort = "recent" | "oldest" | "liked" ;
130+
131+ function hasCommentImages ( item : {
132+ images ?: CommentImageAttachment [ ] ;
133+ imageStoragePath ?: string ;
134+ imageUrl ?: string ;
135+ } ) {
136+ return Boolean (
137+ ( item . images && item . images . length > 0 ) ||
138+ item . imageStoragePath ||
139+ item . imageUrl ,
140+ ) ;
141+ }
142+
130143type CommentReaction = "like" | "dislike" ;
131144
132145type CommentsSectionProps = {
@@ -1357,9 +1370,11 @@ export default function CommentsSection({
13571370 }
13581371 } ;
13591372
1360- const saveReplyEdit = async ( commentId : string , replyId : string ) => {
1373+ const saveReplyEdit = async ( commentId : string , reply : ReplyRecord ) => {
13611374 const trimmedContent = editingReplyContent . trim ( ) ;
1362- if ( ! trimmedContent || trimmedContent . length > MAX_COMMENT_LENGTH ) return ;
1375+ if ( trimmedContent . length > MAX_COMMENT_LENGTH ) return ;
1376+ if ( ! trimmedContent && ! hasCommentImages ( reply ) ) return ;
1377+ const replyId = reply . id ;
13631378 setReplyBusyId ( replyId ) ;
13641379 setError ( "" ) ;
13651380 try {
@@ -1470,9 +1485,11 @@ export default function CommentsSection({
14701485 }
14711486 } ;
14721487
1473- const saveEdit = async ( commentId : string ) => {
1488+ const saveEdit = async ( comment : CommentRecord ) => {
14741489 const trimmedContent = editingContent . trim ( ) ;
1475- if ( ! trimmedContent || trimmedContent . length > MAX_COMMENT_LENGTH ) return ;
1490+ if ( trimmedContent . length > MAX_COMMENT_LENGTH ) return ;
1491+ if ( ! trimmedContent && ! hasCommentImages ( comment ) ) return ;
1492+ const commentId = comment . id ;
14761493 setBusyId ( commentId ) ;
14771494 setError ( "" ) ;
14781495 try {
@@ -2093,8 +2110,11 @@ export default function CommentsSection({
20932110 </ button >
20942111 < button
20952112 type = "button"
2096- onClick = { ( ) => saveEdit ( comment . id ) }
2097- disabled = { busyId === comment . id || ! editingContent . trim ( ) }
2113+ onClick = { ( ) => saveEdit ( comment ) }
2114+ disabled = {
2115+ busyId === comment . id ||
2116+ ( ! editingContent . trim ( ) && ! hasCommentImages ( comment ) )
2117+ }
20982118 className = "group inline-flex items-center gap-2 text-sm font-semibold uppercase transition-colors duration-300 hover:text-[#8a2ae3] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-[#8a2ae3] disabled:opacity-40"
20992119 >
21002120 Save < RiArrowRightLine className = "text-xl" />
@@ -2556,11 +2576,12 @@ export default function CommentsSection({
25562576 < button
25572577 type = "button"
25582578 onClick = { ( ) =>
2559- saveReplyEdit ( comment . id , reply . id )
2579+ saveReplyEdit ( comment . id , reply )
25602580 }
25612581 disabled = {
25622582 replyBusyId === reply . id ||
2563- ! editingReplyContent . trim ( )
2583+ ( ! editingReplyContent . trim ( ) &&
2584+ ! hasCommentImages ( reply ) )
25642585 }
25652586 className = "text-[#8a2ae3] hover:text-white disabled:opacity-35"
25662587 >
0 commit comments