This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch feat/1.3.6/ui in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 780c13c56a95a848ee5d3beea79455c012fb1a61 Author: shuai <[email protected]> AuthorDate: Tue Jul 9 15:31:16 2024 +0800 fix: adjust the sort order on the question page and tag detail page --- ui/src/components/QuestionList/index.tsx | 5 ++--- ui/src/pages/Questions/index.tsx | 11 +++-------- ui/src/pages/Tags/Detail/index.tsx | 11 +++-------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/ui/src/components/QuestionList/index.tsx b/ui/src/components/QuestionList/index.tsx index 94a300d8..2d9c447c 100644 --- a/ui/src/components/QuestionList/index.tsx +++ b/ui/src/components/QuestionList/index.tsx @@ -22,7 +22,6 @@ import { ListGroup } from 'react-bootstrap'; import { NavLink, useSearchParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import type { QuestionOrderBy } from '@/common/interface'; import { pathFactory } from '@/router/pathFactory'; import { Tag, @@ -39,15 +38,15 @@ import * as Type from '@/common/interface'; import { useSkeletonControl } from '@/hooks'; export const QUESTION_ORDER_KEYS: Type.QuestionOrderBy[] = [ - 'active', 'newest', + 'active', 'frequent', 'score', 'unanswered', ]; interface Props { source: 'questions' | 'tag'; - order?: QuestionOrderBy; + order?: Type.QuestionOrderBy; data; isLoading: boolean; } diff --git a/ui/src/pages/Questions/index.tsx b/ui/src/pages/Questions/index.tsx index e0bf27ff..d81a9027 100644 --- a/ui/src/pages/Questions/index.tsx +++ b/ui/src/pages/Questions/index.tsx @@ -36,8 +36,7 @@ import { } from '@/stores'; import { useQuestionList } from '@/services'; import * as Type from '@/common/interface'; -import { userCenter, floppyNavigation, Storage } from '@/utils'; -import { QUESTIONS_ORDER_STORAGE_KEY } from '@/common/constants'; +import { userCenter, floppyNavigation } from '@/utils'; import { QUESTION_ORDER_KEYS } from '@/components/QuestionList'; const Questions: FC = () => { @@ -46,12 +45,8 @@ const Questions: FC = () => { const { user: loggedUser } = loggedUserInfoStore((_) => _); const [urlSearchParams] = useSearchParams(); const curPage = Number(urlSearchParams.get('page')) || 1; - const storageOrder = Storage.get(QUESTIONS_ORDER_STORAGE_KEY); - const curOrder = - urlSearchParams.get('order') || storageOrder || QUESTION_ORDER_KEYS[0]; - if (curOrder !== storageOrder) { - Storage.set(QUESTIONS_ORDER_STORAGE_KEY, curOrder); - } + const curOrder = (urlSearchParams.get('order') || + QUESTION_ORDER_KEYS[0]) as Type.QuestionOrderBy; const reqParams: Type.QueryQuestionsReq = { page_size: 20, page: curPage, diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsx index c2351ce3..a07236da 100644 --- a/ui/src/pages/Tags/Detail/index.tsx +++ b/ui/src/pages/Tags/Detail/index.tsx @@ -38,9 +38,8 @@ import { } from '@/services'; import QuestionList, { QUESTION_ORDER_KEYS } from '@/components/QuestionList'; import HotQuestions from '@/components/HotQuestions'; -import { escapeRemove, guard, Storage, scrollToDocTop } from '@/utils'; +import { escapeRemove, guard, scrollToDocTop } from '@/utils'; import { pathFactory } from '@/router/pathFactory'; -import { QUESTIONS_ORDER_STORAGE_KEY } from '@/common/constants'; const Index: FC = () => { const { t } = useTranslation('translation', { keyPrefix: 'tags' }); @@ -48,12 +47,8 @@ const Index: FC = () => { const routeParams = useParams(); const curTagName = routeParams.tagName || ''; const [urlSearchParams] = useSearchParams(); - const storageOrder = Storage.get(QUESTIONS_ORDER_STORAGE_KEY); - const curOrder = - urlSearchParams.get('order') || storageOrder || QUESTION_ORDER_KEYS[0]; - if (curOrder !== storageOrder) { - Storage.set(QUESTIONS_ORDER_STORAGE_KEY, curOrder); - } + const curOrder = (urlSearchParams.get('order') || + QUESTION_ORDER_KEYS[0]) as Type.QuestionOrderBy; const curPage = Number(urlSearchParams.get('page')) || 1; const reqParams: Type.QueryQuestionsReq = { page_size: 20,
