Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): filter shared links for albums #12255

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

{#if sharedLinks.length}
<a
href={AppRoute.SHARED_LINKS}
href={`${AppRoute.SHARED_LINKS}/album/${album.id}`}
class="flex flex-col place-content-center place-items-center gap-2 hover:cursor-pointer"
>
<Icon path={mdiShareCircle} size={24} />
Expand Down
5 changes: 5 additions & 0 deletions web/src/params/shareType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ParamMatcher } from '@sveltejs/kit';

Check failure on line 1 in web/src/params/shareType.ts

View workflow job for this annotation

GitHub Actions / Web

Filename is not in kebab case. Rename it to `share-type.ts`

export const match: ParamMatcher = (param: string) => {
return param === 'album' || param === 'individual';
};
14 changes: 0 additions & 14 deletions web/src/routes/(user)/sharing/sharedlinks/+page.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@
import { getAllSharedLinks, removeSharedLink, type SharedLinkResponseDto } from '@immich/sdk';
import { mdiArrowLeft } from '@mdi/js';
import { onMount } from 'svelte';
import type { PageData } from './$types';
import { dialogController } from '$lib/components/shared-components/dialog/dialog';
import { t } from 'svelte-i18n';

export let data: PageData;

let sharedLinks: SharedLinkResponseDto[] = [];
let editSharedLink: SharedLinkResponseDto | null = null;

const refresh = async () => {
sharedLinks = await getAllSharedLinks();
if (data.sharedItem.type === 'album') {
sharedLinks = sharedLinks.filter((link) => link.album?.id === data.sharedItem.id);
} else if (data.sharedItem.type === 'individual') {
sharedLinks = sharedLinks.filter((link) => link.assets.some((asset) => asset.id === data.sharedItem.id));
}
};

onMount(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
import { getAlbumInfo } from '@immich/sdk';
import type { PageLoad } from './$types';

export const load = (async ({ params }) => {
await authenticate();

if (params.type === 'album' && params.sharedItemId) {
await getAlbumInfo({ id: params.sharedItemId, withoutAssets: true });
} else if (params.type === 'individual') {
await getAssetInfoFromParam({ assetId: params.sharedItemId });
}
const $t = await getFormatter();

return {
sharedItem: {
type: params.type,
id: params.sharedItemId,
},
meta: {
title: $t('shared_links'),
},
};
}) satisfies PageLoad;
Loading