From c7e8c0bae690d87ceb14ee3be3c0a7074a1cd2e7 Mon Sep 17 00:00:00 2001 From: Wojciech Bandzerewicz <57405495+thewbuk@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:44:58 +0000 Subject: [PATCH] fix namespace switch --- .../src/view/catalog/CatalogMainView.tsx | 2 +- .../components/tabs/CatalogMainTab.tsx | 22 ++----------------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/packages/toolkit/src/view/catalog/CatalogMainView.tsx b/packages/toolkit/src/view/catalog/CatalogMainView.tsx index 38728f7948..6f541e6ab2 100644 --- a/packages/toolkit/src/view/catalog/CatalogMainView.tsx +++ b/packages/toolkit/src/view/catalog/CatalogMainView.tsx @@ -292,7 +292,7 @@ export const CatalogMainView = (props: CatalogViewProps) => { return () => { window.removeEventListener("hashchange", handleHashChange); }; - }, [catalogs.data, changeTab]); + }, [changeTab]); return (
diff --git a/packages/toolkit/src/view/catalog/components/tabs/CatalogMainTab.tsx b/packages/toolkit/src/view/catalog/components/tabs/CatalogMainTab.tsx index b6e2e1184b..36800266b9 100644 --- a/packages/toolkit/src/view/catalog/components/tabs/CatalogMainTab.tsx +++ b/packages/toolkit/src/view/catalog/components/tabs/CatalogMainTab.tsx @@ -17,7 +17,6 @@ import { InstillStore, useCreateNamespaceCatalog, useInstillStore, - useListNamespaceCatalogs, useShallow, useUpdateNamespaceCatalog, } from "../../../../lib"; @@ -66,27 +65,13 @@ export const CatalogTab = ({ const [selectedSortAnchor, setSelectedSortAnchor] = React.useState("createTime"); - const { enabledQuery, selectedNamespace } = useInstillStore( - useShallow(selector), - ); + const { selectedNamespace } = useInstillStore(useShallow(selector)); const createCatalog = useCreateNamespaceCatalog(); const updateCatalog = useUpdateNamespaceCatalog(); const isEnterprisePlan = subscription?.plan === "PLAN_ENTERPRISE"; const isTeamPlan = subscription?.plan === "PLAN_TEAM"; - const catalogState = useListNamespaceCatalogs({ - accessToken, - namespaceId: selectedNamespace ?? null, - enabled: enabledQuery && !!selectedNamespace, - }); - - React.useEffect(() => { - if (selectedNamespace) { - catalogState.refetch(); - } - }, [selectedNamespace, catalogState.refetch, catalogState]); - const handleCreateCatalogSubmit = async ( data: z.infer, ) => { @@ -104,7 +89,6 @@ export const CatalogTab = ({ payload, accessToken, }); - catalogState.refetch(); setIsCreateDialogOpen(false); } catch (error) { console.error("Error creating catalog:", error); @@ -129,7 +113,6 @@ export const CatalogTab = ({ payload, accessToken, }); - catalogState.refetch(); } catch (error) { console.error("Error updating catalog:", error); } @@ -153,7 +136,6 @@ export const CatalogTab = ({ payload: clonedCatalog, accessToken, }); - catalogState.refetch(); } catch (error) { console.error("Error cloning catalog:", error); } @@ -230,7 +212,7 @@ export const CatalogTab = ({ />
- {catalogState.isLoading ? ( + {catalogs === null || catalogs === undefined ? (
{Array.from({ length: 6 }).map((_, index) => (