From 84b07e9bbf185ed6367b928c9e4ccbddf95ce89f Mon Sep 17 00:00:00 2001 From: Laziyni Date: Thu, 9 Feb 2023 16:12:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=B2=20?= =?UTF-8?q?=D1=8E=D0=B7=D1=8D=D1=84=D1=84=D0=B5=D0=BA=D1=82,=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BE=D1=82=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BB=D0=B8=D1=88=D0=BD?= =?UTF-8?q?=D0=B5=D0=B3=D0=BE=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= =?UTF-8?q?=20=D0=B8=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=20=D0=B2=20=D1=81?= =?UTF-8?q?=D0=BB=D0=B0=D0=B9=D1=81=D0=B5=20removAll?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/questions/questions-list/QuestionsList.jsx | 7 +++++-- src/features/questions/questionsSlice.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/features/questions/questions-list/QuestionsList.jsx b/src/features/questions/questions-list/QuestionsList.jsx index bc8d8d3..432d05d 100644 --- a/src/features/questions/questions-list/QuestionsList.jsx +++ b/src/features/questions/questions-list/QuestionsList.jsx @@ -38,6 +38,7 @@ const QuestionsList = () => { const isCompactMode = useSelector(selectIsCompactModeToogle); const questionsIds = useSelector(questionSelectors.selectIds); + const questionsAll = useSelector(questionSelectors.selectAll); const scrollHandler = useCallback( (e) => { @@ -67,8 +68,10 @@ const QuestionsList = () => { }, [deletedOnly, dispatch, favoritesOnly]); useEffect(() => { - dispatch(fetchQuestions({ favoritesOnly, deletedOnly })); - }, [deletedOnly, dispatch, favoritesOnly]); + if (!questionsAll.length) { + dispatch(fetchQuestions({ favoritesOnly, deletedOnly })); + } + }, [deletedOnly, dispatch, favoritesOnly, questionsAll.length]); const QuestionWrapper = isCompactMode ? Paper : React.Fragment; const generatedTitle = generateTitle(deletedOnly, favoritesOnly); diff --git a/src/features/questions/questionsSlice.js b/src/features/questions/questionsSlice.js index c06c824..97e6295 100644 --- a/src/features/questions/questionsSlice.js +++ b/src/features/questions/questionsSlice.js @@ -179,7 +179,7 @@ const questionsSlice = createSlice({ }, [resetQuestionsList]: (state) => { - questionsAdapter.removeAll(state); + // questionsAdapter.removeAll(state); state.pagination.offset = 0; state.pagination.totalQuestions = 0;