Fix/double page mode not aborting preload image requests (#628)

* Use request manager to preload images in DoublePagedPager

Was forgotten to update along with f852ce70e7

The requests for the preload also never got aborted

* Revoke object urls after load
This commit is contained in:
schroda
2024-03-01 18:27:46 +01:00
committed by GitHub
parent d242552751
commit 79d35404d3
5 changed files with 53 additions and 46 deletions

View File

@@ -746,6 +746,19 @@ export class RequestManager {
return `${this.getValidUrlFor(imageUrl, apiVersion)}`;
}
/**
* After the image has been handled, {@see URL#revokeObjectURL} has to be called.
*
* @example
*
* const imageRequest = requestManager.requestImage("someUrl");
* const imageUrl = await imageRequest.response
*
* const img = new Image();
* img.onLoad = () => URL.revokeObjectURL(imageUrl);
* img.src = imageUrl;
*
*/
public requestImage(url: string): { response: Promise<string> } & AbortableRequest {
const { abortRequest, signal } = this.createAbortController();
const response = this.restClient