Files
discord-decomp/modules/global_discovery_apps/utils/getCollectionItemAssetUrl.tsx
T
2026-11-01 12:12:55 +02:00

14 lines
847 B
TypeScript

// Metro module 11298 (f11299).
import { Endpoints } from "../../../Constants";
import { getBestMediaProxySize, getDevicePixelRatio } from "../../image_upload/ImageLoaderUtils";
import { SUPPORTS_WEBP } from "../../../utils/AvatarUtils";
const GLOBAL_ENV = window.GLOBAL_ENV;
const { API_ENDPOINT, CDN_HOST } = GLOBAL_ENV;
export function getCollectionItemAssetUrl({ itemId, hash, containerWidth = 1024 }) {
const r11 = new URLSearchParams({
size: getBestMediaProxySize(containerWidth * getDevicePixelRatio()).toString()
}).toString();
const r10 = SUPPORTS_WEBP ? "webp" : "png";
return CDN_HOST != null ? `https://${CDN_HOST}/app-assets/application-directory/collection-items/${itemId}/${hash}.${r10}?${r11}` : `${location.protocol}${API_ENDPOINT}${Endpoints.APPLICATION_DIRECTORY_COLLECTION_ITEM_IMAGE(itemId, hash, r10)}?${r11}`;
}