fix(web): i18n race condition in load function (#10693)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user