Merge pull request #1074 from JoeMakuta/feature/js-index-maps-optimization

feat: implement map and find optimization
This commit is contained in:
Rohan Verma 2026-04-01 13:07:40 -07:00 committed by GitHub
commit a67e72d159
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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,

View file

@ -157,8 +157,10 @@ export function useInbox(
}) as InboxItem
);
const liveById = new Map(recentItems.map((v) => [v.id, v]));
let updated = prev.map((existing) => {
const liveItem = recentItems.find((v) => v.id === existing.id);
const liveItem = liveById.get(existing.id);
if (liveItem) {
return {
...existing,