feat: support preload for documents with non paged representations#1604
feat: support preload for documents with non paged representations#1604shahzadaziz merged 5 commits intobox:masterfrom
Conversation
| } else if (pagedPreLoadUrlWithAuth) { | ||
| await this.showPreloadAll(preloadUrlWithAuth, pagedPreLoadUrlWithAuth, pages, docBaseViewer); | ||
| } else if (preloadUrlWithAuth && this.config.showPreloadForNonPaged) { | ||
| await this.showPreloadSingleImage(preloadUrlWithAuth, pages, docBaseViewer); |
There was a problem hiding this comment.
Introduce new preload path for non-paged reps. Appllies to JPEG reps for documents <5mb
| ); | ||
| Promise.all(remainingPromises); | ||
| }, secondBatchDelayMs); | ||
| if (secondBatchDelayMs) { |
There was a problem hiding this comment.
what would happen if prefetchPriorityPagesOnly is set to true and secondBatchDelayMs is set to 0. It might not be a configuration that we would set by design. But it would be safer to detect that case and add a default secondBatchDelay here.
There was a problem hiding this comment.
Good call . I will update this.
There was a problem hiding this comment.
ok i see what you were trying to suggest. prefetchPriorityPagesOnly would lead to an early return
if (prefetchPriorityPagesOnly) {
return;
The prefetchPriorityPagesOnly = false and 0 is the problem. I think we might not need this check here tbh.
There was a problem hiding this comment.
I ended up removing this check since we would still want the setTimeout to run. 0 ends up triggering immediately which is desired outcome.
Summary
Introduces showPreloadSingleImage method to support preloading small documents (<5MB) that have non-paged JPEG representations instead of paged WebP. The feature is gated by a new showPreloadForNonPaged config flag to allow controlled rollout.
Key Changes
Config-gated feature: Added config.showPreloadForNonPaged check in showPreload() - when disabled, falls back to showing preview mask