mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-13 12:25:53 +00:00
refactor: asset from param (#25041)
This commit is contained in:
parent
1874557b95
commit
62cc12be3c
17 changed files with 27 additions and 65 deletions
10
web/src/routes/(user)/+layout.ts
Normal file
10
web/src/routes/(user)/+layout.ts
Normal file
|
|
@ -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;
|
||||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue