Browse Source

clean code

jam411 3 years ago
parent
commit
045cc6c52a
1 changed files with 6 additions and 2 deletions
  1. 6 2
      packages/app/src/components/PageComment/Comment.tsx

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

@@ -1,5 +1,6 @@
 import React, { useEffect, useMemo, useState } from 'react';
 import React, { useEffect, useMemo, useState } from 'react';
 
 
+import { IUser } from '@growi/core';
 import { UserPicture } from '@growi/ui';
 import { UserPicture } from '@growi/ui';
 import { format } from 'date-fns';
 import { format } from 'date-fns';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
@@ -9,7 +10,6 @@ import { UncontrolledTooltip } from 'reactstrap';
 import { useCommentPreviewOptions } from '~/stores/renderer';
 import { useCommentPreviewOptions } from '~/stores/renderer';
 
 
 import { ICommentHasId } from '../../interfaces/comment';
 import { ICommentHasId } from '../../interfaces/comment';
-import { IUser } from '../../interfaces/user';
 import FormattedDistanceDate from '../FormattedDistanceDate';
 import FormattedDistanceDate from '../FormattedDistanceDate';
 import HistoryIcon from '../Icons/HistoryIcon';
 import HistoryIcon from '../Icons/HistoryIcon';
 import RevisionRenderer from '../Page/RevisionRenderer';
 import RevisionRenderer from '../Page/RevisionRenderer';
@@ -52,6 +52,10 @@ export const Comment = (props: CommentProps): JSX.Element => {
   const isEdited = createdAt < updatedAt;
   const isEdited = createdAt < updatedAt;
 
 
   useEffect(() => {
   useEffect(() => {
+    if (revisionId == null) {
+      return;
+    }
+
     setMarkdown(comment.comment);
     setMarkdown(comment.comment);
 
 
     const isCurrentRevision = () => {
     const isCurrentRevision = () => {
@@ -72,7 +76,7 @@ export const Comment = (props: CommentProps): JSX.Element => {
     let className = 'page-comment flex-column';
     let className = 'page-comment flex-column';
 
 
     // Conditional for called from SearchResultContext
     // Conditional for called from SearchResultContext
-    if (revisionCreatedAt != null) {
+    if (revisionId != null && revisionCreatedAt != null) {
       if (comment.revision === revisionId) {
       if (comment.revision === revisionId) {
         className += ' page-comment-current';
         className += ' page-comment-current';
       }
       }