High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat: cache shared link (#27889)
Daniel Dietzler41968fdcac24
diff --git a/web/src/lib/utils/shared-links.ts b/web/src/lib/utils/shared-links.tsindex 423eda310c..77cca76aea 100644--- a/web/src/lib/utils/shared-links.ts+++ b/web/src/lib/utils/shared-links.ts@@ -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;