1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

useWsInventories cleanup

This commit is contained in:
Keith Grant 2020-07-10 08:33:35 -07:00
parent f225df1acd
commit 38e0968690

View File

@ -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);
})();