From f9938edb7599afa95da5033d7614ecf5220e6b4c Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:25:58 +0100 Subject: [PATCH] Extract aborting image requests into function --- src/lib/requests/RequestManager.ts | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index 47c9681b..a1985d73 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -891,17 +891,7 @@ export class RequestManager { return { response, - abortRequest: (reason?: any) => { - if (this.imageQueue.isProcessing(key)) { - // prevent aborting image requests that are already in progress - // e.g. for source image requests, ongoing requests are already handled by the server and aborting them - // will just cause new source image requests to be sent to the server, which then will cause the server - // to become really slow for image requests to the same source - return; - } - - abortRequest(reason); - }, + abortRequest: (reason?: any) => this.abortImageRequest(key, () => abortRequest(reason)), cleanup: () => {}, }; } @@ -945,17 +935,7 @@ export class RequestManager { return { response, - abortRequest: (reason?: any) => { - if (this.imageQueue.isProcessing(key)) { - // prevent aborting image requests that are already in progress - // e.g. for source image requests, ongoing requests are already handled by the server and aborting them - // will just cause new source image requests to be sent to the server, which then will cause the server - // to become really slow for image requests to the same source - return; - } - - abortRequest(reason); - }, + abortRequest: (reason?: any) => this.abortImageRequest(key, () => abortRequest(reason)), cleanup: () => URL.revokeObjectURL(objectUrl), }; }