mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 01:11:16 +03:00
feat: preload and cancel images with a service worker (#16893)
* feat: Service Worker to preload/cancel images and other resources * Remove caddy configuration, localhost is secure if port-forwarded * fix e2e tests * Cache/return the app.html for all web entry points * Only handle preload/cancel * fix e2e * fix e2e * e2e-2 * that'll do it * format * fix test * lint * refactor common code to conditionals --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
import { thumbhash } from '$lib/actions/thumbhash';
|
||||
import BrokenAsset from '$lib/components/assets/broken-asset.svelte';
|
||||
import Icon from '$lib/components/elements/icon.svelte';
|
||||
import { cancelImageUrl } from '$lib/utils/sw-messaging';
|
||||
import { TUNABLES } from '$lib/utils/tunables';
|
||||
import { mdiEyeOffOutline } from '@mdi/js';
|
||||
import type { ClassValue } from 'svelte/elements';
|
||||
import type { ActionReturn } from 'svelte/action';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
interface Props {
|
||||
@@ -59,11 +61,14 @@
|
||||
onComplete?.(true);
|
||||
};
|
||||
|
||||
function mount(elem: HTMLImageElement) {
|
||||
function mount(elem: HTMLImageElement): ActionReturn {
|
||||
if (elem.complete) {
|
||||
loaded = true;
|
||||
onComplete?.(false);
|
||||
}
|
||||
return {
|
||||
destroy: () => cancelImageUrl(url),
|
||||
};
|
||||
}
|
||||
|
||||
let optionalClasses = $derived(
|
||||
|
||||
Reference in New Issue
Block a user