From ce2aa1657b9cb11d2570de7c251836ce3bcf977f Mon Sep 17 00:00:00 2001 From: wafaanasr Date: Fri, 2 Dec 2022 13:36:01 +0100 Subject: [PATCH] remove unused code --- .../add_to_lists_table/index.tsx | 4 ++-- .../use_add_to_lists_table.tsx | 21 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/index.tsx index e5fe3770c2484..5957ee0b49e21 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_exceptions/components/flyout_components/add_to_lists_table/index.tsx @@ -21,7 +21,7 @@ const ExceptionsAddToListsComponent: React.FC( - - ); const [error, setError] = useState(undefined); @@ -83,21 +79,21 @@ export const useAddToSharedListTable = ({ } }, [listsToFetch]); - useEffect(() => { - getReferences(); - }, [listsToFetch, getReferences]); - - useEffect(() => { + const fillListsToDisplay = useCallback(async () => { + await getReferences(); if (exceptionListReferences) { const lists: ExceptionListRuleReferencesSchema[] = []; for (const [_, value] of Object.entries(exceptionListReferences)) if (value.type === ExceptionListTypeEnum.DETECTION) lists.push(value); - setMessage(undefined); setListsToDisplay(lists); setIsLoading(false); } - }, [exceptionListReferences, showAllSharedLists]); + }, [exceptionListReferences, getReferences]); + + useEffect(() => { + fillListsToDisplay(); + }, [listsToFetch, getReferences, fillListsToDisplay]); useEffect(() => { onListSelectionChange( @@ -148,9 +144,8 @@ export const useAddToSharedListTable = ({ return { error, isLoading, - message, pagination, - sortedLists: listsToDisplay, + lists: listsToDisplay, listTableColumnsWithLinkSwitch, addToSelectedListDescription: i18n.ADD_TO_LISTS_DESCRIPTION, onTableChange,