diff --git a/projects/plugins/protect/src/js/hooks/use-fixers.ts b/projects/plugins/protect/src/js/hooks/use-fixers.ts index e4eee1cd19003..c8c6e67506d7c 100644 --- a/projects/plugins/protect/src/js/hooks/use-fixers.ts +++ b/projects/plugins/protect/src/js/hooks/use-fixers.ts @@ -1,4 +1,3 @@ -import { useMemo } from 'react'; import useFixersMutation from '../data/scan/use-fixers-mutation'; import useFixersQuery from '../data/scan/use-fixers-query'; import useScanStatusQuery from '../data/scan/use-scan-status-query'; @@ -10,45 +9,10 @@ import useScanStatusQuery from '../data/scan/use-scan-status-query'; */ export default function useFixers() { const { data: status } = useScanStatusQuery(); + const { fixableThreats } = status; const fixersMutation = useFixersMutation(); - const fixableThreats = useMemo( () => { - const result = []; - status.core?.threats.forEach( threat => { - if ( threat.fixable ) { - result.push( threat ); - } - } ); - status.plugins?.forEach( plugin => { - plugin.threats.forEach( threat => { - if ( threat.fixable ) { - result.push( threat ); - } - } ); - } ); - status.themes?.forEach( theme => { - theme.threats.forEach( threat => { - if ( threat.fixable ) { - result.push( threat ); - } - } ); - } ); - status.files?.forEach( threat => { - if ( threat.fixable ) { - result.push( threat ); - } - } ); - status.database?.forEach( threat => { - if ( threat.fixable ) { - result.push( threat ); - } - } ); - return result; - }, [ status ] ); - - const { data: fixersStatus } = useFixersQuery( { - threatIds: fixableThreats.map( threat => parseInt( threat.id ) ), - } ); + const { data: fixersStatus } = useFixersQuery( { threatIds: fixableThreats } ); const fixThreats = async ( threatIds: number[] ) => fixersMutation.mutateAsync( threatIds );