diff --git a/apps/dotcom/src/utils/assetHandler.ts b/apps/dotcom/src/utils/assetHandler.ts index 83a165b0a..1e9c98569 100644 --- a/apps/dotcom/src/utils/assetHandler.ts +++ b/apps/dotcom/src/utils/assetHandler.ts @@ -15,12 +15,6 @@ export const resolveAsset = async (asset: TLAsset | null | undefined, context: AssetContextProps) => { if (!asset || !asset.props.src) return null - // We don't deal with videos at the moment. - if (asset.type === 'video') return asset.props.src - - // Assert it's an image to make TS happy. - if (asset.type !== 'image') return null - // Retrieve a local image from the DB. if (persistenceKey && asset.props.src.startsWith('asset:')) { return await objectURLCache.get( @@ -29,6 +23,12 @@ export const resolveAsset = ) } + // We don't deal with videos at the moment. + if (asset.type === 'video') return asset.props.src + + // Assert it's an image to make TS happy. + if (asset.type !== 'image') return null + // Don't try to transform data: URLs, yikes. if (!asset.props.src.startsWith('http:') && !asset.props.src.startsWith('https:')) return asset.props.src diff --git a/packages/tldraw/src/lib/defaultExternalContentHandlers.ts b/packages/tldraw/src/lib/defaultExternalContentHandlers.ts index 3c024b739..75d2c29e3 100644 --- a/packages/tldraw/src/lib/defaultExternalContentHandlers.ts +++ b/packages/tldraw/src/lib/defaultExternalContentHandlers.ts @@ -580,12 +580,6 @@ export const defaultResolveAsset = (persistenceKey?: string) => async (asset: TLAsset | null | undefined) => { if (!asset || !asset.props.src) return null - // We don't deal with videos at the moment. - if (asset.type === 'video') return asset.props.src - - // Assert it's an image to make TS happy. - if (asset.type !== 'image') return null - // Retrieve a local image from the DB. if (persistenceKey && asset.props.src.startsWith('asset:')) { return await objectURLCache.get( @@ -594,6 +588,12 @@ export const defaultResolveAsset = ) } + // We don't deal with videos at the moment. + if (asset.type === 'video') return asset.props.src + + // Assert it's an image to make TS happy. + if (asset.type !== 'image') return null + return asset.props.src }