diff --git a/ui/src/components/Comment/index.tsx b/ui/src/components/Comment/index.tsx index d76f94d6..f96ca77e 100644 --- a/ui/src/components/Comment/index.tsx +++ b/ui/src/components/Comment/index.tsx @@ -24,7 +24,7 @@ import { Form, ActionBar, Reply } from './components'; import './index.scss'; -const Comment = ({ objectId, mode }) => { +const Comment = ({ objectId, mode, commentId }) => { const pageUsers = usePageUsers(); const [pageIndex, setPageIndex] = useState(0); const [comments, setComments] = useState([]); @@ -32,6 +32,7 @@ const Comment = ({ objectId, mode }) => { const pageSize = pageIndex === 0 ? 3 : 15; const { data, mutate } = useQueryComments({ object_id: objectId, + commentId, page: pageIndex, page_size: pageSize, }); diff --git a/ui/src/pages/Questions/Detail/components/Answer/index.tsx b/ui/src/pages/Questions/Detail/components/Answer/index.tsx index 43e8627b..d1b76be7 100644 --- a/ui/src/pages/Questions/Detail/components/Answer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Answer/index.tsx @@ -1,7 +1,7 @@ import { memo, FC, useEffect, useRef } from 'react'; import { Row, Col, Button } from 'react-bootstrap'; import { useTranslation } from 'react-i18next'; -import { Link } from 'react-router-dom'; +import { Link, useSearchParams } from 'react-router-dom'; import { Actions, @@ -37,6 +37,7 @@ const Index: FC = ({ const { t } = useTranslation('translation', { keyPrefix: 'question_detail', }); + const [searchParams] = useSearchParams(); const answerRef = useRef(null); const acceptAnswer = () => { acceptanceAnswer({ @@ -152,7 +153,11 @@ const Index: FC = ({ - + ); }; diff --git a/ui/src/pages/Questions/Detail/components/Question/index.tsx b/ui/src/pages/Questions/Detail/components/Question/index.tsx index 812cb306..92bdd235 100644 --- a/ui/src/pages/Questions/Detail/components/Question/index.tsx +++ b/ui/src/pages/Questions/Detail/components/Question/index.tsx @@ -1,5 +1,5 @@ import { memo, FC, useState, useEffect, useRef } from 'react'; -import { Link } from 'react-router-dom'; +import { Link, useSearchParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Row, Col, Button } from 'react-bootstrap'; @@ -26,6 +26,7 @@ const Index: FC = ({ data, initPage, hasAnswer, isLogged }) => { const { t } = useTranslation('translation', { keyPrefix: 'question_detail', }); + const [searchParams] = useSearchParams(); const [followed, setFollowed] = useState(data?.is_followed); const ref = useRef(null); @@ -164,7 +165,11 @@ const Index: FC = ({ data, initPage, hasAnswer, isLogged }) => { - + ); }; diff --git a/ui/src/services/common.ts b/ui/src/services/common.ts index 43437d6e..54ea69dc 100644 --- a/ui/src/services/common.ts +++ b/ui/src/services/common.ts @@ -38,6 +38,9 @@ export const useQueryComments = (params) => { if (params.page === 0) { params.query_cond = 'vote'; params.page = 1; + } else { + // only first page need commentId + delete params.commentId; } return useSWR( `/answer/api/v1/comment/page?${qs.stringify(params, {