Open History to see the last commit
1import type { AssetResource, EnvironmentId } from "@t3tools/contracts";
2import type { ImageSource } from "expo-image";
3
4/** Cache immutable attachments by id; signed URLs change on each mint and reconnect. */
5export function assetImageSource(
6 environmentId: EnvironmentId,
7 resource: AssetResource,
8 uri: string,
9): ImageSource {
10 return resource._tag === "attachment"
11 ? {
12 uri,
13 cacheKey: `t3-attachment:${JSON.stringify([environmentId, resource.attachmentId])}`,
14 }
15 : { uri };
16}