feat: implement map and find optimization

This commit is contained in:
JoeMakuta 2026-04-01 18:47:57 +02:00
parent b1631cd6f1
commit 03a24686fe
3 changed files with 11 additions and 6 deletions

View file

@ -246,9 +246,11 @@ export function useDocuments(
status: (doc.status as unknown as DocumentStatusType) ?? { state: "ready" },
}));
const liveById = new Map(validItems.map((v) => [v.id, v]));
let updated = prev.map((existing) => {
if (liveIds.has(existing.id)) {
const liveItem = validItems.find((v) => v.id === existing.id);
const liveItem = liveById.get(existing.id);
if (liveItem) {
return {
...existing,