From 38e09686907288fb8276c22de00126987cdcf189 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Fri, 10 Jul 2020 08:33:35 -0700 Subject: [PATCH] useWsInventories cleanup --- .../screens/Inventory/InventoryList/useWsInventories.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/awx/ui_next/src/screens/Inventory/InventoryList/useWsInventories.js b/awx/ui_next/src/screens/Inventory/InventoryList/useWsInventories.js index 13871490f3..eea15f9a2c 100644 --- a/awx/ui_next/src/screens/Inventory/InventoryList/useWsInventories.js +++ b/awx/ui_next/src/screens/Inventory/InventoryList/useWsInventories.js @@ -34,17 +34,13 @@ export default function useWsProjects( const newInventories = await fetchInventoriesById( throttledInventoriesToFetch ); - let updated = inventories; + const updated = [...inventories]; newInventories.forEach(inventory => { const index = inventories.findIndex(i => i.id === inventory.id); if (index === -1) { return; } - updated = [ - ...updated.slice(0, index), - inventory, - ...updated.slice(index + 1), - ]; + updated[index] = inventory; }); setInventories(updated); })();