fix(web): i18n race condition in load function (#10693)

This commit is contained in:
Michel Heusschen
2024-06-29 18:29:56 +02:00
committed by GitHub
parent 24c1855899
commit 8f553ddb39
31 changed files with 74 additions and 89 deletions
@@ -1,22 +1,21 @@
import { getAssetThumbnailUrl, setSharedLink } from '$lib/utils';
import { authenticate } from '$lib/utils/auth';
import { getFormatter } from '$lib/utils/i18n';
import { getAssetInfoFromParam } from '$lib/utils/navigation';
import { getMySharedLink, isHttpError } from '@immich/sdk';
import { t } from 'svelte-i18n';
import { get } from 'svelte/store';
import type { PageLoad } from './$types';
export const load = (async ({ params }) => {
const { key } = params;
await authenticate({ public: true });
const asset = await getAssetInfoFromParam(params);
const $t = get(t);
try {
const sharedLink = await getMySharedLink({ key });
setSharedLink(sharedLink);
const assetCount = sharedLink.assets.length;
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;
const $t = await getFormatter();
return {
sharedLink,
@@ -30,6 +29,7 @@ export const load = (async ({ params }) => {
};
} catch (error) {
if (isHttpError(error) && error.data.message === 'Invalid password') {
const $t = await getFormatter();
return {
passwordRequired: true,
sharedLinkKey: key,