From ad34ee502302a2ceb61285663e661d80e1dc6f9f Mon Sep 17 00:00:00 2001 From: iberdinsky-skilld Date: Thu, 12 Sep 2024 18:37:40 +0200 Subject: [PATCH] Linter fix --- client/src/components/GlobalKBarProvider.tsx | 40 ++++++++++++-------- client/src/components/SidebarTree.tsx | 8 +++- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/client/src/components/GlobalKBarProvider.tsx b/client/src/components/GlobalKBarProvider.tsx index d7250f3..cb973db 100644 --- a/client/src/components/GlobalKBarProvider.tsx +++ b/client/src/components/GlobalKBarProvider.tsx @@ -19,21 +19,29 @@ export const GlobalKBarProvider: FC = ({ children }) => { const dispatch = useActionDispatch() const navigate = useNavigate() - if (!isError && !isLoading) { - const kbar: KBarProviderProps['actions'] = [] - data?.data?.forEach((action) => { - kbar.push({ - id: action.id, - name: `${action.title} (${action.id})`, - perform: () => { - navigate('/flow') - dispatch?.({ - type: 'set-active-action', - id: action.id, - }) - }, - }) - }) - return {children} + if (isError) { + return null + } + + if (isLoading) { + return null } + + const kbar: KBarProviderProps['actions'] = [] + + data?.data?.forEach((action) => { + kbar.push({ + id: action.id, + name: `${action.title} (${action.id})`, + perform: () => { + navigate('/flow') + dispatch?.({ + type: 'set-active-action', + id: action.id, + }) + }, + }) + }) + + return {children} } diff --git a/client/src/components/SidebarTree.tsx b/client/src/components/SidebarTree.tsx index 2b90df9..ed0dca1 100644 --- a/client/src/components/SidebarTree.tsx +++ b/client/src/components/SidebarTree.tsx @@ -347,11 +347,15 @@ export const SidebarTree: FC<{ })() setExpandedItems(expandItems.reverse()) if (selectedAction) { - const prevSelectedAction = apiRef.current?.getItem(selectedAction) + const prevSelectedAction = ( + apiRef.current as { getItem: (id: string) => any } + )?.getItem(selectedAction) prevSelectedAction.selected = false setSelectedAction('') } - const curSelectedAction = apiRef.current?.getItem(nodeId) + const curSelectedAction = ( + apiRef.current as { getItem: (id: string) => any } + )?.getItem(nodeId) if (curSelectedAction?.selected) { curSelectedAction.selected = nodeId }