mirror of
https://github.com/immich-app/immich.git
synced 2026-07-30 23:50:36 -07:00
chore(deps): update dependency eslint-plugin-unicorn to v70 - abandoned (#29684)
* chore(deps): update dependency eslint-plugin-unicorn to v70 * fix: linting --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Daniel Dietzler
parent
8061a2e5ff
commit
df970da59e
@@ -24,7 +24,7 @@ const handleFetch = (event: FetchEvent): void => {
|
||||
|
||||
// Cache requests for thumbnails
|
||||
const url = new URL(event.request.url);
|
||||
if (url.origin === self.location.origin && ASSET_REQUEST_REGEX.test(url.pathname)) {
|
||||
if (url.origin === globalThis.location.origin && ASSET_REQUEST_REGEX.test(url.pathname)) {
|
||||
event.respondWith(handleAssetFetch(event.request));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export const installMessageListener = () => {
|
||||
|
||||
switch (event.data.type) {
|
||||
case 'cancel': {
|
||||
const url = event.data.url ? new URL(event.data.url, self.location.origin) : undefined;
|
||||
const url = event.data.url ? new URL(event.data.url, globalThis.location.origin) : undefined;
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,14 @@ const getRequestKey = (request: URL | Request): string => (request instanceof UR
|
||||
const CANCELATION_MESSAGE = 'Request canceled by application';
|
||||
const CLEANUP_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
|
||||
|
||||
export const handleFetch = (request: URL | Request): Promise<Response> => {
|
||||
export const handleFetch = async (request: URL | Request): Promise<Response> => {
|
||||
const requestKey = getRequestKey(request);
|
||||
const existing = pendingRequests.get(requestKey);
|
||||
|
||||
if (existing) {
|
||||
// Clone the response since response bodies can only be read once
|
||||
// Each caller gets an independent clone they can consume
|
||||
// eslint-disable-next-line unicorn/prefer-await
|
||||
return existing.promise.then((response) => response.clone());
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ export const handleFetch = (request: URL | Request): Promise<Response> => {
|
||||
|
||||
// NOTE: fetch returns after headers received, not the body
|
||||
pendingRequest.promise = fetch(request, { signal: pendingRequest.controller.signal })
|
||||
// eslint-disable-next-line unicorn/prefer-await
|
||||
.catch((error: unknown) => {
|
||||
const standardError = error instanceof Error ? error : new Error(String(error));
|
||||
if (standardError.name === 'AbortError' || standardError.message === CANCELATION_MESSAGE) {
|
||||
@@ -43,6 +45,7 @@ export const handleFetch = (request: URL | Request): Promise<Response> => {
|
||||
}
|
||||
throw standardError;
|
||||
})
|
||||
// eslint-disable-next-line unicorn/prefer-await
|
||||
.finally(() => {
|
||||
// Schedule cleanup after timeout to allow response body streaming to complete
|
||||
const cleanupTimeout = setTimeout(() => {
|
||||
@@ -52,6 +55,7 @@ export const handleFetch = (request: URL | Request): Promise<Response> => {
|
||||
});
|
||||
|
||||
// Clone for the first caller to keep the original response unconsumed for future callers
|
||||
// eslint-disable-next-line unicorn/prefer-await
|
||||
return pendingRequest.promise.then((response) => response.clone());
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user