Просмотр исходного кода

Merge branch 'master' into fix/113887-search-from-tag-tree

yuken 3 лет назад
Родитель
Сommit
67f4b469b9

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

@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
 
 
 import { IUser, pathUtils } from '@growi/core';
 import { IUser, pathUtils } from '@growi/core';
 import { UserPicture } from '@growi/ui';
 import { UserPicture } from '@growi/ui';
-import { format } from 'date-fns';
+import { format, parseISO } from 'date-fns';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 import Link from 'next/link';
 import Link from 'next/link';
 import { UncontrolledTooltip } from 'reactstrap';
 import { UncontrolledTooltip } from 'reactstrap';
@@ -79,12 +79,18 @@ export const Comment = (props: CommentProps): JSX.Element => {
   const getRootClassName = (comment: ICommentHasId) => {
   const getRootClassName = (comment: ICommentHasId) => {
     let className = 'page-comment flex-column';
     let className = 'page-comment flex-column';
 
 
+    // TODO: fix so that `comment.createdAt` to be type Date https://redmine.weseek.co.jp/issues/113876
+    let commentCreatedAt = comment.createdAt;
+    if (typeof commentCreatedAt === 'string') {
+      commentCreatedAt = parseISO(commentCreatedAt);
+    }
+
     // Conditional for called from SearchResultContext
     // Conditional for called from SearchResultContext
     if (revisionId != null && revisionCreatedAt != null) {
     if (revisionId != null && revisionCreatedAt != null) {
       if (comment.revision === revisionId) {
       if (comment.revision === revisionId) {
         className += ' page-comment-current';
         className += ' page-comment-current';
       }
       }
-      else if (comment.createdAt.getTime() > revisionCreatedAt.getTime()) {
+      else if (commentCreatedAt.getTime() > revisionCreatedAt.getTime()) {
         className += ' page-comment-newer';
         className += ' page-comment-newer';
       }
       }
       else {
       else {

+ 3 - 0
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -55,6 +55,9 @@ const markTarget = (children: ItemNode[], targetPathOrId?: Nullable<string>): vo
     if (node.page._id === targetPathOrId || node.page.path === targetPathOrId) {
     if (node.page._id === targetPathOrId || node.page.path === targetPathOrId) {
       node.page.isTarget = true;
       node.page.isTarget = true;
     }
     }
+    else {
+      node.page.isTarget = false;
+    }
     return node;
     return node;
   });
   });
 };
 };