diff --git a/app/src/components/Loader.js b/app/src/components/Loader.js index 7a9977c6e..5da3627ed 100644 --- a/app/src/components/Loader.js +++ b/app/src/components/Loader.js @@ -56,9 +56,12 @@ export const refreshTriggerState = atom({ }); export const mergeItems = (oldItems, newItems = []) => { - const newItemsIds = newItems?.map((i) => i._id) || []; - const oldItemsPurged = oldItems.filter((i) => !newItemsIds.includes(i._id)); - return [...oldItemsPurged, ...newItems].filter((e) => !e.deletedAt); + const newItemIds = {}; + for (const newItem of newItems) { + newItemIds[newItem._id] = true; + } + const oldItemsPurged = oldItems.filter((item) => !newItemIds[item._id] && !item.deletedAt); + return [...oldItemsPurged, ...newItems.filter((item) => !item.deletedAt)]; }; export const DataLoader = () => { diff --git a/dashboard/src/components/DataLoader.js b/dashboard/src/components/DataLoader.js index b3a3b2d24..534dafb45 100644 --- a/dashboard/src/components/DataLoader.js +++ b/dashboard/src/components/DataLoader.js @@ -468,9 +468,12 @@ export function useDataLoader(options = { refreshOnMount: false }) { } export const mergeItems = (oldItems, newItems = []) => { - const newItemsIds = newItems?.map((i) => i._id) || []; - const oldItemsPurged = oldItems.filter((i) => !newItemsIds.includes(i._id)); - return [...oldItemsPurged, ...newItems].filter((e) => !e.deletedAt); + const newItemIds = {}; + for (const newItem of newItems) { + newItemIds[newItem._id] = true; + } + const oldItemsPurged = oldItems.filter((item) => !newItemIds[item._id] && !item.deletedAt); + return [...oldItemsPurged, ...newItems.filter((item) => !item.deletedAt)]; }; const FullScreenContainer = styled.div`