yuto-oweseek 4 лет назад
Родитель
Сommit
181cac8db2
1 измененных файлов с 11 добавлено и 11 удалено
  1. 11 11
      packages/app/src/components/PageComment.tsx

+ 11 - 11
packages/app/src/components/PageComment.tsx

@@ -128,6 +128,14 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
     />
     />
   );
   );
 
 
+  const removeShowEditorId = useCallback((commentId: string) => {
+    setShowEditorIds((previousState) => {
+      const previousShowEditorIds = new Set(...previousState);
+      previousShowEditorIds.delete(commentId);
+      return previousShowEditorIds;
+    });
+  }, []);
+
 
 
   if (commentsFromOldest == null || commentsExceptReply == null) return <></>;
   if (commentsFromOldest == null || commentsExceptReply == null) return <></>;
 
 
@@ -148,6 +156,7 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
 
 
                 let commentThreadClasses = '';
                 let commentThreadClasses = '';
                 commentThreadClasses = hasReply ? `${defaultCommentThreadClasses} page-comment-thread-no-replies` : defaultCommentThreadClasses;
                 commentThreadClasses = hasReply ? `${defaultCommentThreadClasses} page-comment-thread-no-replies` : defaultCommentThreadClasses;
+
                 return (
                 return (
                   <div key={comment._id} className={commentThreadClasses}>
                   <div key={comment._id} className={commentThreadClasses}>
                     {/* display comment */}
                     {/* display comment */}
@@ -176,20 +185,11 @@ const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
                         growiRenderer={appContainer.getRenderer('comment')}
                         growiRenderer={appContainer.getRenderer('comment')}
                         replyTo={comment._id}
                         replyTo={comment._id}
                         onCancelButtonClicked={() => {
                         onCancelButtonClicked={() => {
-                          setShowEditorIds((previousState) => {
-                            const tmp = new Set(...previousState);
-                            tmp.delete(comment._id);
-                            return tmp;
-                          });
+                          removeShowEditorId(comment._id);
                         }}
                         }}
                         onCommentButtonClicked={() => {
                         onCommentButtonClicked={() => {
-                          setShowEditorIds((previousState) => {
-                            const tmp = new Set(...previousState);
-                            tmp.delete(comment._id);
-                            return tmp;
-                          });
+                          removeShowEditorId(comment._id);
                           mutate();
                           mutate();
-
                         }}
                         }}
                       />
                       />
                     )}
                     )}