High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
refactor: asset from param (#25041)
Jason Rasmussen62cc12be3c98
diff --git a/web/src/routes/(user)/+layout.ts b/web/src/routes/(user)/+layout.tsnew file mode 100644index 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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.tsindex 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'),},