Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jul 12, 2023
1 parent 11d965b commit 941f7a5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions packages/legacy-compat/src/legacy-network-handler/fetch-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,19 @@ function _flushPendingFetchForType(store: Store, pendingFetchItems: PendingFetch
let totalItems = pendingFetchItems.length;

if (shouldCoalesce) {
let nonGroupableItems: PendingFetchItem[] = [];
let snapshots = new Array<Snapshot>(totalItems);
let fetchMap = new Map<Snapshot, PendingFetchItem>();
for (let i = 0; i < totalItems; i++) {
let fetchItem = pendingFetchItems[i];
if (fetchItem.options?.include?.length) {
nonGroupableItems.push(fetchItem);
continue;
}
if (fetchItem.options?.adapterOptions && Object.keys(fetchItem.options.adapterOptions).length > 0) {
nonGroupableItems.push(fetchItem);
continue;
}
snapshots[i] = store._fetchManager.createSnapshot(fetchItem.identifier, fetchItem.options);
fetchMap.set(snapshots[i], fetchItem);
}
Expand All @@ -531,10 +540,12 @@ function _flushPendingFetchForType(store: Store, pendingFetchItems: PendingFetch
for (let i = 0, l = groups.length; i < l; i++) {
_processCoalescedGroup(store, fetchMap, groups[i], adapter, modelName);
}
} else {
for (let i = 0; i < totalItems; i++) {
void _fetchRecord(store, adapter, pendingFetchItems[i]);
}
totalItems = nonGroupableItems.length;
pendingFetchItems = nonGroupableItems;
}

for (let i = 0; i < totalItems; i++) {
void _fetchRecord(store, adapter, pendingFetchItems[i]);
}
}

Expand Down

0 comments on commit 941f7a5

Please sign in to comment.