From c19397c65dffe61e2b30c07789da97a3d07d2b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Cvitanovi=C4=87?= <72022639+petar-cvit@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:18:58 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9B=93=EF=B8=8F=20fetch=20module=20list=20pe?= =?UTF-8?q?riodicaly=20(#577)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fetch module list periodicaly * fetch module list periodicaly * single fetching func --- .../src/components/pages/Modules/Modules.tsx | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/cyclops-ui/src/components/pages/Modules/Modules.tsx b/cyclops-ui/src/components/pages/Modules/Modules.tsx index 10167665..d58ea970 100644 --- a/cyclops-ui/src/components/pages/Modules/Modules.tsx +++ b/cyclops-ui/src/components/pages/Modules/Modules.tsx @@ -45,18 +45,27 @@ const Modules = () => { useEffect(() => { setLoadingModules(true); - axios - .get(`/api/modules/list`) - .then((res) => { - setAllData(res.data); - setFilteredData(res.data); - setLoadingModules(false); - }) - .catch((error) => { - setError(mapResponseError(error)); - setLoadingModules(false); - }); + + function fetchModules() { + axios + .get(`/api/modules/list`) + .then((res) => { + setAllData(res.data); + setLoadingModules(false); + }) + .catch((error) => { + setError(mapResponseError(error)); + setLoadingModules(false); + }); + } + + fetchModules(); + const interval = setInterval(() => fetchModules(), 10000); + return () => { + clearInterval(interval); + }; }, []); + useEffect(() => { var updatedList = [...allData]; updatedList = updatedList.filter((module: any) => {