Skip to content

Commit

Permalink
feat(new-ui): add ref image prefetch in new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jan 15, 2025
1 parent 714f54f commit 947a530
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/static/modules/utils/imageEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ function hasDiffImage(image: ImageEntity): image is ImageEntityFail {
return Object.hasOwn(image, 'diffImg');
}

function hasRefImage(image: ImageEntity): image is ImageEntityFail {
return Object.hasOwn(image, 'refImg');
}

export function preloadImageEntity(image: ImageEntity): () => void {
const elements: HTMLElement[] = [];

Expand All @@ -40,6 +44,10 @@ export function preloadImageEntity(image: ImageEntity): () => void {
elements.push(preloadImage(image.diffImg.path));
}

if (hasRefImage(image)) {
elements.push(preloadImage(image.refImg.path));
}

return (): void => {
elements.forEach(element => element.remove());
};
Expand Down

0 comments on commit 947a530

Please sign in to comment.