A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.
fix: adjust the sort order on the question page and tag detail page
shuai780c13c56a95
diff --git a/ui/src/components/QuestionList/index.tsx b/ui/src/components/QuestionList/index.tsxindex 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.tsxindex 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.tsxindex 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,