feat(web): use thumbhash as a cache key (#16106)

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen
2025-02-15 22:34:13 -05:00
committed by GitHub
parent c524fcf084
commit f386b4d377
8 changed files with 41 additions and 38 deletions

View File

@@ -180,28 +180,30 @@ const createUrl = (path: string, parameters?: Record<string, unknown>) => {
return getBaseUrl() + url.pathname + url.search + url.hash;
};
export const getAssetOriginalUrl = (options: string | { id: string; checksum?: string }) => {
type AssetUrlOptions = { id: string; cacheKey?: string | null };
export const getAssetOriginalUrl = (options: string | AssetUrlOptions) => {
if (typeof options === 'string') {
options = { id: options };
}
const { id, checksum } = options;
return createUrl(getAssetOriginalPath(id), { key: getKey(), c: checksum });
const { id, cacheKey } = options;
return createUrl(getAssetOriginalPath(id), { key: getKey(), c: cacheKey });
};
export const getAssetThumbnailUrl = (options: string | { id: string; size?: AssetMediaSize; checksum?: string }) => {
export const getAssetThumbnailUrl = (options: string | (AssetUrlOptions & { size?: AssetMediaSize })) => {
if (typeof options === 'string') {
options = { id: options };
}
const { id, size, checksum } = options;
return createUrl(getAssetThumbnailPath(id), { size, key: getKey(), c: checksum });
const { id, size, cacheKey } = options;
return createUrl(getAssetThumbnailPath(id), { size, key: getKey(), c: cacheKey });
};
export const getAssetPlaybackUrl = (options: string | { id: string; checksum?: string }) => {
export const getAssetPlaybackUrl = (options: string | AssetUrlOptions) => {
if (typeof options === 'string') {
options = { id: options };
}
const { id, checksum } = options;
return createUrl(getAssetPlaybackPath(id), { key: getKey(), c: checksum });
const { id, cacheKey } = options;
return createUrl(getAssetPlaybackPath(id), { key: getKey(), c: cacheKey });
};
export const getProfileImageUrl = (user: UserResponseDto) =>