Skip to content

Open source CapCut alternative.

TypeScript

fix(cut): only video and audio refs show a length

David Le863dd41af418
diff --git a/site/src/cut/components/AssetRefs.tsx b/site/src/cut/components/AssetRefs.tsx
index fafd333b..4a8911f8 100644
--- a/site/src/cut/components/AssetRefs.tsx
+++ b/site/src/cut/components/AssetRefs.tsx
@@ -130,8 +130,9 @@ export function RefThumb({ item, className }: { item: AssetRef; className?: stri
) : (
<AudioPillSurface peaks={peaks} className="size-full rounded-none" />
)}
- {/* One badge: the pinned moment when the user chose one, the length otherwise. */}
- {(item.t !== undefined || (item.duration !== undefined && item.kind !== "image")) && (
+ {/* One badge: the pinned moment when the user chose one, the length
+ otherwise. Only media that plays has either. */}
+ {(item.kind === "video" || item.kind === "audio") && (item.t ?? item.duration) !== undefined && (
<span className="absolute right-1 bottom-1 rounded-[5px] bg-black/65 px-1 py-px font-mono text-[8.5px] text-white tabular-nums">
{formatTime(item.t ?? item.duration!)}
</span>
diff --git a/site/src/cut/lib/assetRef.ts b/site/src/cut/lib/assetRef.ts
index 1c3f6342..67829620 100644
--- a/site/src/cut/lib/assetRef.ts
+++ b/site/src/cut/lib/assetRef.ts
@@ -171,7 +171,7 @@ export const refFromAsset = (a: MediaAsset): AssetRef => ({
// them out of the @-mention candidates; the arm only keeps the mapping total.
kind: isLinkedAssetType(a.type) ? "text" : a.type,
url: a.url,
- duration: a.duration,
+ ...(isLinkedAssetType(a.type) ? {} : { duration: a.duration }),
});
export const refFromLibrary = (a: LibraryAsset): AssetRef => ({
@@ -184,7 +184,7 @@ export const refFromLibrary = (a: LibraryAsset): AssetRef => ({
// thread — so it carries the shelf route rather than a minted URL that
// expires inside the hour.
url: libraryRouteUrl(a.fileName, a.residency),
- duration: a.duration,
+ ...(isLinkedAssetType(a.type) ? {} : { duration: a.duration }),
...(a.width !== undefined ? { width: a.width } : {}),
...(a.height !== undefined ? { height: a.height } : {}),
...(a.posterFile ? { thumb: libraryRouteUrl(a.posterFile, a.residency) } : {}),