From 62cc12be3c98972f62cf6c51077e26827ab099a5 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Mon, 5 Jan 2026 11:26:58 -0500 Subject: [PATCH] refactor: asset from param (#25041) --- web/src/routes/(user)/+layout.ts | 10 ++++++++++ .../[[photos=photos]]/[[assetId=id]]/+page.ts | 7 +------ .../archive/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../folders/[[photos=photos]]/[[assetId=id]]/+page.ts | 6 ++---- .../locked/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../map/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../memory/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts | 3 --- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- web/src/routes/(user)/photos/[[assetId=id]]/+page.ts | 5 +---- .../search/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../tags/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../trash/[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- web/src/routes/(user)/utilities/+page.ts | 5 +---- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 5 +---- .../[[photos=photos]]/[[assetId=id]]/+page.ts | 6 ++---- 17 files changed, 27 insertions(+), 65 deletions(-) create mode 100644 web/src/routes/(user)/+layout.ts diff --git a/web/src/routes/(user)/+layout.ts b/web/src/routes/(user)/+layout.ts new file mode 100644 index 0000000000..1fa655774f --- /dev/null +++ b/web/src/routes/(user)/+layout.ts @@ -0,0 +1,10 @@ +import { getAssetInfoFromParam } from '$lib/utils/navigation'; +import type { LayoutLoad } from './$types'; + +export const load = (async ({ params }) => { + const asset = await getAssetInfoFromParam(params); + + return { + asset, + }; +}) satisfies LayoutLoad; diff --git a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.ts index f8691b5fd1..359bb84ca5 100644 --- a/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/albums/[albumId=id]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,18 +1,13 @@ import { authenticate } from '$lib/utils/auth'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getAlbumInfo } from '@immich/sdk'; import type { PageLoad } from './$types'; export const load = (async ({ params, url }) => { await authenticate(url); - const [album, asset] = await Promise.all([ - getAlbumInfo({ id: params.albumId, withoutAssets: true }), - getAssetInfoFromParam(params), - ]); + const album = await getAlbumInfo({ id: params.albumId, withoutAssets: true }); return { album, - asset, meta: { title: album.albumName, }, diff --git a/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts index f5d4560505..55e7279cce 100644 --- a/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/archive/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('archive'), }, diff --git a/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts index 0d9fe7a203..21d3dacdac 100644 --- a/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/favorites/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('favorites'), }, diff --git a/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts index 72fb102e53..df7f3a20e1 100644 --- a/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/folders/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -2,12 +2,11 @@ import { QueryParameter } from '$lib/constants'; import { foldersStore } from '$lib/stores/folders.svelte'; import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const [, asset, $t] = await Promise.all([foldersStore.fetchTree(), getAssetInfoFromParam(params), getFormatter()]); + const [, $t] = await Promise.all([foldersStore.fetchTree(), getFormatter()]); let tree = foldersStore.folders!; const path = url.searchParams.get(QueryParameter.PATH); @@ -23,7 +22,6 @@ export const load = (async ({ params, url }) => { const pathAssets = tree.hasAssets ? await foldersStore.fetchAssetsByPath(tree.path) : null; return { - asset, tree, pathAssets, meta: { diff --git a/web/src/routes/(user)/locked/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/locked/[[photos=photos]]/[[assetId=id]]/+page.ts index cf2e415da0..e9ae8c0dbe 100644 --- a/web/src/routes/(user)/locked/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/locked/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,12 +1,11 @@ import { AppRoute } from '$lib/constants'; import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getAuthStatus } from '@immich/sdk'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); const { isElevated, pinCode } = await getAuthStatus(); @@ -14,11 +13,9 @@ export const load = (async ({ params, url }) => { redirect(302, `${AppRoute.AUTH_PIN_PROMPT}?continue=${encodeURIComponent(url.pathname + url.search)}`); } - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('locked_folder'), }, diff --git a/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts index add9882bcd..359ae8f332 100644 --- a/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/map/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('map'), }, diff --git a/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts index 5c030da72f..784eeeb6bf 100644 --- a/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/memory/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,16 +1,13 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { const user = await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { user, - asset, meta: { title: $t('memory'), }, diff --git a/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts index 1977d9a095..28f6e512ac 100644 --- a/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/partners/[userId]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,6 +1,5 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getUser } from '@immich/sdk'; import type { PageLoad } from './$types'; @@ -8,11 +7,9 @@ export const load = (async ({ params, url }) => { await authenticate(url); const partner = await getUser({ id: params.userId }); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, partner, meta: { title: $t('partner'), diff --git a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts index 92371bd34e..97c27914ca 100644 --- a/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/people/[personId]/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,23 +1,20 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getPerson, getPersonStatistics } from '@immich/sdk'; import type { PageLoad } from './$types'; export const load = (async ({ params, url }) => { await authenticate(url); - const [person, statistics, asset] = await Promise.all([ + const [person, statistics] = await Promise.all([ getPerson({ id: params.personId }), getPersonStatistics({ id: params.personId }), - getAssetInfoFromParam(params), ]); const $t = await getFormatter(); return { person, statistics, - asset, meta: { title: person.name || $t('person'), }, diff --git a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts index 209b5483a8..b4751c1807 100644 --- a/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/photos/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('photos'), }, diff --git a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts index 82dd18acaa..56a8a33c15 100644 --- a/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/search/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('search'), }, diff --git a/web/src/routes/(user)/tags/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/tags/[[photos=photos]]/[[assetId=id]]/+page.ts index 225d79a38d..d64aec53ad 100644 --- a/web/src/routes/(user)/tags/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/tags/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,13 +1,11 @@ import { QueryParameter } from '$lib/constants'; import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getAllTags } from '@immich/sdk'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); const tags = await getAllTags(); @@ -15,7 +13,6 @@ export const load = (async ({ params, url }) => { return { path: url.searchParams.get(QueryParameter.PATH) ?? '', tags, - asset, meta: { title: $t('tags'), }, diff --git a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts index 79c41892c7..2d32448620 100644 --- a/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/trash/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('trash'), }, diff --git a/web/src/routes/(user)/utilities/+page.ts b/web/src/routes/(user)/utilities/+page.ts index af241d0fd7..dbb939495b 100644 --- a/web/src/routes/(user)/utilities/+page.ts +++ b/web/src/routes/(user)/utilities/+page.ts @@ -1,15 +1,12 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const $t = await getFormatter(); return { - asset, meta: { title: $t('utilities'), }, diff --git a/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts index 978f50830e..8d21861fc5 100644 --- a/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/utilities/duplicates/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,17 +1,14 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { getAssetDuplicates } from '@immich/sdk'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const asset = await getAssetInfoFromParam(params); const duplicates = await getAssetDuplicates(); const $t = await getFormatter(); return { - asset, duplicates, meta: { title: $t('duplicates'), diff --git a/web/src/routes/(user)/utilities/large-files/[[photos=photos]]/[[assetId=id]]/+page.ts b/web/src/routes/(user)/utilities/large-files/[[photos=photos]]/[[assetId=id]]/+page.ts index 19754bcff2..6780fdb023 100644 --- a/web/src/routes/(user)/utilities/large-files/[[photos=photos]]/[[assetId=id]]/+page.ts +++ b/web/src/routes/(user)/utilities/large-files/[[photos=photos]]/[[assetId=id]]/+page.ts @@ -1,17 +1,15 @@ import { authenticate } from '$lib/utils/auth'; import { getFormatter } from '$lib/utils/i18n'; -import { getAssetInfoFromParam } from '$lib/utils/navigation'; import { searchLargeAssets } from '@immich/sdk'; import type { PageLoad } from './$types'; -export const load = (async ({ params, url }) => { +export const load = (async ({ url }) => { await authenticate(url); - const [assets, asset] = await Promise.all([searchLargeAssets({ minFileSize: 0 }), getAssetInfoFromParam(params)]); + const assets = await searchLargeAssets({ minFileSize: 0 }); const $t = await getFormatter(); return { assets, - asset, meta: { title: $t('large_files'), },