assets: fix up videos with indexedDB (#3954)

Whoops, the logic needs to check for `asset:` first before videos.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [x] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [x] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know
This commit is contained in:
Mime Čuvalo 2024-06-17 11:58:37 +01:00 committed by GitHub
parent e491cba863
commit 5b3fc7dffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View file

@ -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

View file

@ -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
}