{#snippet buttons()}
diff --git a/web/src/routes/(user)/shared-links/(list)/+layout.ts b/web/src/routes/(user)/shared-links/(list)/+layout.ts
index 842940ffe..cf7224751 100644
--- a/web/src/routes/(user)/shared-links/(list)/+layout.ts
+++ b/web/src/routes/(user)/shared-links/(list)/+layout.ts
@@ -1,9 +1,12 @@
+import { queryClient } from '$lib/queries/client';
+import { getAllSharedLinksQuery } from '$lib/queries/shared-link.query';
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import type { LayoutLoad } from './$types';
export const load = (async ({ url }) => {
await authenticate(url);
+ await queryClient.query(getAllSharedLinksQuery());
const $t = await getFormatter();
return {
diff --git a/web/src/routes/(user)/shared-links/(list)/[id]/+layout.ts b/web/src/routes/(user)/shared-links/(list)/[id]/+layout.ts
index 50e55c798..75ad0f42c 100644
--- a/web/src/routes/(user)/shared-links/(list)/[id]/+layout.ts
+++ b/web/src/routes/(user)/shared-links/(list)/[id]/+layout.ts
@@ -1,6 +1,7 @@
-import { getAllSharedLinks } from '@immich/sdk';
import { redirect } from '@sveltejs/kit';
import { UUID_REGEX } from '$lib/constants';
+import { queryClient } from '$lib/queries/client';
+import { getSharedLinkQuery } from '$lib/queries/shared-link.query';
import { Route } from '$lib/route';
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
@@ -13,15 +14,11 @@ export const load = (async ({ params, url }) => {
redirect(307, Route.sharedLinks());
}
- const [sharedLink] = await getAllSharedLinks({ id: params.id });
- if (!sharedLink) {
- redirect(307, Route.sharedLinks());
- }
+ await queryClient.query(getSharedLinkQuery(params.id)).catch(() => redirect(307, Route.sharedLinks()));
const $t = await getFormatter();
return {
- sharedLink,
meta: {
title: $t('shared_links'),
},
diff --git a/web/src/routes/(user)/shared-links/(list)/[id]/edit/+page.svelte b/web/src/routes/(user)/shared-links/(list)/[id]/edit/+page.svelte
index ac069ff08..8615b9977 100644
--- a/web/src/routes/(user)/shared-links/(list)/[id]/edit/+page.svelte
+++ b/web/src/routes/(user)/shared-links/(list)/[id]/edit/+page.svelte
@@ -2,20 +2,18 @@
import { goto } from '$app/navigation';
import SharedLinkFormFields from '$lib/components/SharedLinkFormFields.svelte';
import { Route } from '$lib/route';
- import { handleUpdateSharedLink } from '$lib/services/shared-link.service';
+ import { createPreloadedQuery, executeMutation } from '$lib/queries/client';
+ import { getSharedLinkQuery, updateSharedLinkMutation } from '$lib/queries/shared-link.query';
import { SharedLinkType } from '@immich/sdk';
import { FormModal } from '@immich/ui';
import { mdiLink } from '@mdi/js';
import { t } from 'svelte-i18n';
- import type { PageData } from './$types';
+ import type { PageProps } from './$types';
- type Props = {
- data: PageData;
- };
+ const { params }: PageProps = $props();
- let { data }: Props = $props();
-
- const sharedLink = $state(data.sharedLink);
+ const query = createPreloadedQuery(() => getSharedLinkQuery(params.id));
+ const sharedLink = $derived(query.data);
let description = $state(sharedLink.description ?? '');
let allowDownload = $state(sharedLink.allowDownload);
@@ -26,12 +24,9 @@
let shareType = sharedLink.album ? SharedLinkType.Album : SharedLinkType.Individual;
let expiresAt = $state(sharedLink.expiresAt);
- const onClose = async () => {
- await goto(Route.sharedLinks());
- };
-
+ const onClose = () => void goto(Route.sharedLinks());
const onSubmit = async () => {
- const success = await handleUpdateSharedLink(sharedLink, {
+ const sharedLinkEditDto = {
description,
password: password ?? null,
expiresAt,
@@ -39,10 +34,8 @@
allowDownload,
showMetadata,
slug: slug.trim() ?? null,
- });
- if (success) {
- await onClose();
- }
+ };
+ await executeMutation(updateSharedLinkMutation, [{ id: sharedLink.id, sharedLinkEditDto }], { onSuccess: onClose });
};