From c7d9fc8508d271f41bcc358b8df995951436a431 Mon Sep 17 00:00:00 2001 From: Shossy Date: Mon, 8 Jul 2024 23:29:53 +0300 Subject: [PATCH 1/2] feat: fixed issue with sources content not displayed when select same source twice in a row --- .../components/modals/Sources/SourcesModal.component.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/common/components/modals/Sources/SourcesModal.component.tsx b/src/app/common/components/modals/Sources/SourcesModal.component.tsx index b0597327b..395daecf3 100644 --- a/src/app/common/components/modals/Sources/SourcesModal.component.tsx +++ b/src/app/common/components/modals/Sources/SourcesModal.component.tsx @@ -23,12 +23,10 @@ const SourcesModal = () => { const [content, setContent] = useState(null); const categoryId = sources.fromCardId!; const category = srcCategoriesMap.get(categoryId); - const clickHandle = () => { - sources.isOpen = false; - setContent(null); - }; + const clickHandle = () => sources.isOpen = false; - useAsync(() => { + + useAsync(async () => { setContent(srcCategoriesContentMap.get(categoryId) || null); }, [categoryId]); return ( From ff180462c21ad18e25fcc2f09acc6db791fa998f Mon Sep 17 00:00:00 2001 From: Shossy Date: Mon, 8 Jul 2024 23:40:45 +0300 Subject: [PATCH 2/2] removed async statement since it is not used in async context --- .../components/modals/Sources/SourcesModal.component.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/app/common/components/modals/Sources/SourcesModal.component.tsx b/src/app/common/components/modals/Sources/SourcesModal.component.tsx index 395daecf3..34eb368a8 100644 --- a/src/app/common/components/modals/Sources/SourcesModal.component.tsx +++ b/src/app/common/components/modals/Sources/SourcesModal.component.tsx @@ -1,7 +1,7 @@ import './SourcesModal.styles.scss'; import { observer } from 'mobx-react-lite'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import sourcesApi from '@api/sources/sources.api'; import CancelBtn from '@assets/images/utils/Cancel_btn.svg'; import CancelBtnMobile from '@assets/images/utils/Cancel_btn_mobile.svg'; @@ -17,7 +17,6 @@ import { StreetcodeCategoryContent } from '@/models/sources/sources.model'; const SourcesModal = () => { const { sourcesStore: { srcCategoriesMap, srcCategoriesContentMap } } = useMobx(); const { modalStore } = useModalContext(); - const { streetcodeStore } = useStreetcodeDataContext(); const { setModal, modalsState: { sources } } = modalStore; const windowsize = useWindowSize(); const [content, setContent] = useState(null); @@ -26,7 +25,7 @@ const SourcesModal = () => { const clickHandle = () => sources.isOpen = false; - useAsync(async () => { + useEffect(() => { setContent(srcCategoriesContentMap.get(categoryId) || null); }, [categoryId]); return (