mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 12:15:47 -04:00
feat(web): permanent url in shared link (#9083)
This commit is contained in:
parent
adb607c3ee
commit
912d0c4d74
@ -18,8 +18,8 @@ export const isPeopleRoute = (route?: string | null) => !!route?.startsWith('/(u
|
|||||||
export const isAssetViewerRoute = (target?: NavigationTarget | null) =>
|
export const isAssetViewerRoute = (target?: NavigationTarget | null) =>
|
||||||
!!(target?.route.id?.endsWith('/[[assetId=id]]') && 'assetId' in (target?.params || {}));
|
!!(target?.route.id?.endsWith('/[[assetId=id]]') && 'assetId' in (target?.params || {}));
|
||||||
|
|
||||||
export function getAssetInfoFromParam({ assetId }: { assetId?: string }) {
|
export function getAssetInfoFromParam({ assetId, key }: { assetId?: string; key?: string }) {
|
||||||
return assetId && getAssetInfo({ id: assetId });
|
return assetId && getAssetInfo({ id: assetId, key });
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentUrlWithoutAsset() {
|
function currentUrlWithoutAsset() {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils';
|
import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils';
|
||||||
import { authenticate } from '$lib/utils/auth';
|
import { authenticate } from '$lib/utils/auth';
|
||||||
|
import { getAssetInfoFromParam } from '$lib/utils/navigation';
|
||||||
import { ThumbnailFormat, getMySharedLink, isHttpError } from '@immich/sdk';
|
import { ThumbnailFormat, getMySharedLink, isHttpError } from '@immich/sdk';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
export const load = (async ({ params }) => {
|
export const load = (async ({ params }) => {
|
||||||
const { key } = params;
|
const { key } = params;
|
||||||
await authenticate({ public: true });
|
await authenticate({ public: true });
|
||||||
|
const asset = await getAssetInfoFromParam(params);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const sharedLink = await getMySharedLink({ key });
|
const sharedLink = await getMySharedLink({ key });
|
||||||
@ -15,6 +17,8 @@ export const load = (async ({ params }) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
sharedLink,
|
sharedLink,
|
||||||
|
asset,
|
||||||
|
key,
|
||||||
meta: {
|
meta: {
|
||||||
title: sharedLink.album ? sharedLink.album.albumName : 'Public Share',
|
title: sharedLink.album ? sharedLink.album.albumName : 'Public Share',
|
||||||
description: sharedLink.description || `${assetCount} shared photos & videos.`,
|
description: sharedLink.description || `${assetCount} shared photos & videos.`,
|
@ -1,17 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import AssetViewer from '$lib/components/asset-viewer/asset-viewer.svelte';
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
import { AppRoute } from '$lib/constants';
|
|
||||||
export let data: PageData;
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if data.asset && data.key}
|
|
||||||
<AssetViewer
|
|
||||||
asset={data.asset}
|
|
||||||
showNavigation={false}
|
|
||||||
on:previous={() => null}
|
|
||||||
on:next={() => null}
|
|
||||||
on:close={() => goto(`${AppRoute.SHARE}/${data.key}`)}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
@ -1,15 +0,0 @@
|
|||||||
import { getAssetInfo } from '@immich/sdk';
|
|
||||||
import type { PageLoad } from './$types';
|
|
||||||
|
|
||||||
export const load = (async ({ params }) => {
|
|
||||||
const { key, assetId } = params;
|
|
||||||
const asset = await getAssetInfo({ id: assetId, key });
|
|
||||||
|
|
||||||
return {
|
|
||||||
asset,
|
|
||||||
key,
|
|
||||||
meta: {
|
|
||||||
title: 'Public Share',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}) satisfies PageLoad;
|
|
Loading…
x
Reference in New Issue
Block a user