1
0
mirror of https://github.com/immich-app/immich.git synced 2025-01-12 15:32:36 +02:00

feat(web): permanent url in shared link (#9083)

This commit is contained in:
Alex 2024-04-25 14:32:21 -05:00 committed by GitHub
parent adb607c3ee
commit 912d0c4d74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 6 additions and 34 deletions

View File

@ -18,8 +18,8 @@ export const isPeopleRoute = (route?: string | null) => !!route?.startsWith('/(u
export const isAssetViewerRoute = (target?: NavigationTarget | null) =>
!!(target?.route.id?.endsWith('/[[assetId=id]]') && 'assetId' in (target?.params || {}));
export function getAssetInfoFromParam({ assetId }: { assetId?: string }) {
return assetId && getAssetInfo({ id: assetId });
export function getAssetInfoFromParam({ assetId, key }: { assetId?: string; key?: string }) {
return assetId && getAssetInfo({ id: assetId, key });
}
function currentUrlWithoutAsset() {

View File

@ -1,11 +1,13 @@
import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils';
import { authenticate } from '$lib/utils/auth';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
import { ThumbnailFormat, getMySharedLink, isHttpError } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async ({ params }) => {
const { key } = params;
await authenticate({ public: true });
const asset = await getAssetInfoFromParam(params);
try {
const sharedLink = await getMySharedLink({ key });
@ -15,6 +17,8 @@ export const load = (async ({ params }) => {
return {
sharedLink,
asset,
key,
meta: {
title: sharedLink.album ? sharedLink.album.albumName : 'Public Share',
description: sharedLink.description || `${assetCount} shared photos & videos.`,

View File

@ -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}

View File

@ -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;