mirror of
https://github.com/immich-app/immich.git
synced 2026-01-26 03:14:39 -08:00
16 lines
467 B
TypeScript
16 lines
467 B
TypeScript
import { ServiceWorkerMessenger } from './sw-messenger';
|
|
|
|
const messenger = new ServiceWorkerMessenger();
|
|
const hasServiceWorker = globalThis.isSecureContext && 'serviceWorker' in navigator;
|
|
|
|
const isValidSwContext = (url: string | undefined | null): url is string => {
|
|
return hasServiceWorker && !!url;
|
|
};
|
|
|
|
export function cancelImageUrl(url: string | undefined | null) {
|
|
if (!isValidSwContext(url)) {
|
|
return;
|
|
}
|
|
void messenger.send('cancel', { url });
|
|
}
|