jam411 3 лет назад
Родитель
Сommit
e2d13d0d6f

+ 2 - 3
packages/app/src/components/PageComment.tsx

@@ -134,7 +134,7 @@ export const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
   if (hideIfEmpty && comments?.length === 0) {
     return <></>;
   }
-  if (rendererOptions == null) {
+  if (rendererOptions == null || currentPagePath == null) {
     return <></>;
   }
 
@@ -146,12 +146,11 @@ export const PageComment:FC<Props> = memo((props:Props):JSX.Element => {
         comment={comment}
         onComment={mutate}
         isReadOnly={isReadOnly}
-        page={currentPagePath}
+        currentPagePath={currentPagePath}
         currentRevisionId={currentPage.revision._id}
         currentRevisionCreatedAt={currentPage.revision.createdAt}
       />
     )
-
   );
 
   let commentTitleClasses = 'border-bottom py-3 mb-3';

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

@@ -24,14 +24,14 @@ type CommentProps = {
   deleteBtnClicked: (comment: ICommentHasId) => void,
   onComment: () => void,
   rendererOptions: RendererOptions,
-  page: any,
-  currentRevisionId: any, // TODO: check type
-  currentRevisionCreatedAt: any, // TODO: check type
+  currentPagePath: string,
+  currentRevisionId: string,
+  currentRevisionCreatedAt: Date,
 }
 
 export const Comment = (props: CommentProps): JSX.Element => {
   const {
-    comment, isReadOnly, deleteBtnClicked, onComment, rendererOptions, page, currentRevisionId, currentRevisionCreatedAt,
+    comment, isReadOnly, deleteBtnClicked, onComment, rendererOptions, currentPagePath, currentRevisionId, currentRevisionCreatedAt,
   } = props;
   const { t } = useTranslation();
   const { data: currentUser } = useCurrentUser();
@@ -46,6 +46,11 @@ export const Comment = (props: CommentProps): JSX.Element => {
   const updatedAt = new Date(comment.updatedAt);
   const isEdited = createdAt < updatedAt;
 
+  // TODO: Remove when update ReplayComments.jsx
+  if (currentPagePath == null) {
+    return <></>;
+  }
+
   useEffect(() => {
     setMarkdown(comment.comment);
 
@@ -71,7 +76,7 @@ export const Comment = (props: CommentProps): JSX.Element => {
     if (comment.revision === currentRevisionId) {
       className += ' page-comment-current';
     }
-    else if (Date.parse(comment.createdAt) / 1000 > currentRevisionCreatedAt) {
+    else if (Date.parse(comment.createdAt) / 1000 > Date.parse(currentRevisionCreatedAt.toString())) {
       className += ' page-comment-newer';
     }
     else {
@@ -99,7 +104,7 @@ export const Comment = (props: CommentProps): JSX.Element => {
         rendererOptions={rendererOptions}
         markdown={markdown}
         additionalClassName="comment"
-        pagePath={page}
+        pagePath={currentPagePath}
       />
     );
   };

+ 1 - 1
packages/app/src/services/renderer/renderer.tsx

@@ -345,7 +345,7 @@ export const generateCommentPreviewOptions: ReactMarkdownOptionsGenerator = (con
   // add remark plugins
   if (remarkPlugins != null) {
     remarkPlugins.push(emoji);
-    if (config.isEnabledLinebreaks) {
+    if (config.isEnabledLinebreaksInComments) {
       remarkPlugins.push(breaks);
     }
   }