diff --git a/src/pages/HomePage/HomePage.jsx b/src/pages/HomePage/HomePage.jsx index 7eea060..7af56c3 100644 --- a/src/pages/HomePage/HomePage.jsx +++ b/src/pages/HomePage/HomePage.jsx @@ -27,31 +27,35 @@ const HomePage = ({ const dispatch = useDispatch(); const [techParams, setTechParams] = useState(isTech); + const [previousTechParams, setPreviousTechParams] = useState(isTech); const onSelectTech = (value) => { setIsLoading(true); + setPreviousTechParams(isTech); setTechParams(value); dispatch(setSortByRoles(value)); }; useEffect(() => { if (domains.length === 0) { - if (isTech === 'init') { - (async () => { - await fetchDomains(0, false, isTech); - setIsLoading(false); - })(); - } else { - (async () => { - await fetchDomains(0, false, isTech); - setIsLoading(false); - })(); - } - } else { + (async () => { + await fetchDomains(0, false, isTech); + setIsLoading(false); + })(); + } + else if (previousTechParams !== isTech) { + (async () => { + await fetchDomains(0, false, isTech); + setIsLoading(false); + })(); + } + else { setIsLoading(false); } }, [fetchDomains, isTech]); + console.log(totalDomains); + if (isLoading) return ; return ( diff --git a/src/redux/reducers/domains.js b/src/redux/reducers/domains.js index 804dbbc..0c08367 100644 --- a/src/redux/reducers/domains.js +++ b/src/redux/reducers/domains.js @@ -143,30 +143,6 @@ const failDomainUnlock = (payload) => ({ type: UNLOCK_DOMAIN_FAILURE, }); -// const fetchRawDomainList = async (isTech) => { -// let offset = 0; -// let domains = []; -// let count = 0; - -// let res = await api.fetchDomains(null, offset, false, isTech); -// domains = domains.concat(res.data.domains); -// count = res.data.count; -// if (offset < count) { -// offset += 200; -// } else { -// return domains; -// } - -// while (offset < count) { -// res = api.fetchDomains(null, offset, false); -// domains = domains.concat(res.data.domains); -// if (offset < count) { -// offset += 200; -// } -// } -// return domains; -// }; - const fetchDomain = (uuid) => (dispatch) => { dispatch(requestDomain()); return api @@ -368,5 +344,4 @@ export { lockDomain, parseDomain, unlockDomain, - // fetchRawDomainList, };