Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions packages/runtime/runtime-utils/src/snapshotUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ export function isSnapshotFetchRequiredForLoadingGroupId(
snapshotTree: ISnapshotTree,
blobContents: Map<string, ArrayBuffer>,
): boolean {
for (const [_, id] of Object.entries(snapshotTree.blobs)) {
if (!blobContents.has(id)) {
return true;
}
}
for (const [_, childTree] of Object.entries(snapshotTree.trees)) {
// Only evaluate childTree if it does not have a loading groupId because if the childTree has a loading
// groupId then it will be evaluated whether we want to fetch blobs for that childTree or not when
// that particular childTree is getting realized. Now we just want to check for blobs which belongs to
// tree with current loading groupId. Note: Child with no loading groupId, will fall under parent with
// a loading groupId as it does not have its own loading groupId.
if (childTree.groupId === undefined) {
const value = isSnapshotFetchRequiredForLoadingGroupId(childTree, blobContents);
if (value) {
const trees = [snapshotTree];
let tree: ISnapshotTree | undefined;
while ((tree = trees.pop()) !== undefined) {
for (const [_, id] of Object.entries(tree.blobs)) {
if (!blobContents.has(id)) {
return true;
}
}
for (const [_, childTree] of Object.entries(tree.trees)) {
// Only evaluate childTree if it does not have a loading groupId because if the childTree has a loading
// groupId then it will be evaluated whether we want to fetch blobs for that childTree or not when
// that particular childTree is getting realized. Now we just want to check for blobs which belongs to
// tree with current loading groupId. Note: Child with no loading groupId, will fall under parent with
// a loading groupId as it does not have its own loading groupId.
if (childTree.groupId === undefined) {
trees.push(childTree);
}
}
}
return false;
}
Loading