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(QuestionList): Make the Tag details page remember how to sort the list of questions too
haitaooae90d4b8ad63
diff --git a/ui/src/components/QuestionList/index.tsx b/ui/src/components/QuestionList/index.tsxindex 0911a945..bbf07612 100644--- a/ui/src/components/QuestionList/index.tsx+++ b/ui/src/components/QuestionList/index.tsx@@ -17,6 +17,8 @@ import {Icon,} from '@/components';import * as Type from '@/common/interface';+import { Storage } from '@/utils';+import { QUESTIONS_ORDER_STORAGE_KEY } from '@/common/constants';export const QUESTION_ORDER_KEYS: Type.QuestionOrderBy[] = ['active',@@ -40,8 +42,17 @@ const QuestionList: FC<Props> = ({}) => {const { t } = useTranslation('translation', { keyPrefix: 'question' });const [urlSearchParams] = useSearchParams();++ const storageOrder = Storage.get(QUESTIONS_ORDER_STORAGE_KEY);const curOrder =- order || urlSearchParams.get('order') || QUESTION_ORDER_KEYS[0];+ order ||+ urlSearchParams.get('order') ||+ storageOrder ||+ QUESTION_ORDER_KEYS[0];+ if (curOrder !== storageOrder) {+ Storage.set(QUESTIONS_ORDER_STORAGE_KEY, curOrder);+ }+const curPage = Number(urlSearchParams.get('page')) || 1;const pageSize = 20;const count = data?.count || 0;diff --git a/ui/src/pages/Tags/Detail/index.tsx b/ui/src/pages/Tags/Detail/index.tsxindex 3144bc7b..ffd5341e 100644--- a/ui/src/pages/Tags/Detail/index.tsx+++ b/ui/src/pages/Tags/Detail/index.tsx@@ -22,7 +22,7 @@ import HotQuestions from '@/components/HotQuestions';import { escapeRemove, guard } from '@/utils';import { pathFactory } from '@/router/pathFactory';-const Questions: FC = () => {+const Index: FC = () => {const { t } = useTranslation('translation', { keyPrefix: 'tags' });const navigate = useNavigate();const routeParams = useParams();@@ -159,4 +159,4 @@ const Questions: FC = () => {);};-export default Questions;+export default Index;