mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: cache shared link (#27889)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { getAssetMediaUrl, setSharedLink } from '$lib/utils';
|
||||
import { getAssetMediaUrl, getSharedLink as getCachedSharedLink, setSharedLink } from '$lib/utils';
|
||||
import { authenticate } from '$lib/utils/auth';
|
||||
import { getFormatter } from '$lib/utils/i18n';
|
||||
import { getAssetInfoFromParam } from '$lib/utils/navigation';
|
||||
@@ -28,11 +28,16 @@ export const loadSharedLink = async ({
|
||||
await authenticate(url, { public: true });
|
||||
|
||||
const common = { key, slug };
|
||||
|
||||
const $t = await getFormatter();
|
||||
|
||||
const cachedSharedLink = getCachedSharedLink();
|
||||
const sharedLinkPromise =
|
||||
cachedSharedLink && (key === cachedSharedLink.key || slug === cachedSharedLink.slug)
|
||||
? Promise.resolve(cachedSharedLink)
|
||||
: getMySharedLink({ key, slug });
|
||||
|
||||
try {
|
||||
const [sharedLink, asset] = await Promise.all([getMySharedLink({ key, slug }), getAssetInfoFromParam(params)]);
|
||||
const [sharedLink, asset] = await Promise.all([sharedLinkPromise, getAssetInfoFromParam(params)]);
|
||||
setSharedLink(sharedLink);
|
||||
const assetCount = sharedLink.assets.length;
|
||||
const assetId = sharedLink.album?.albumThumbnailAssetId || sharedLink.assets[0]?.id;
|
||||
|
||||
Reference in New Issue
Block a user