fix(dashboard): recut duration display and stale durable URL
- A recut clip's start/end are the covering source range, so end - start showed a 20s two-segment clip as minutes long; duration now sums the recipe segments when present. - Drop the clip's durable R2 URL after a rerender: archive_clip_edit deletes the superseded object, so the stale URL would 404 as the playback fallback.
This commit is contained in:
parent
a0e25828fd
commit
d1bf36c666
2 changed files with 23 additions and 2 deletions
|
|
@ -309,6 +309,14 @@ function App() {
|
|||
: c)),
|
||||
};
|
||||
});
|
||||
// The old durable R2 object is deleted when the recut is archived, so the
|
||||
// stale URL would 404 as a fallback; drop it until the next refresh.
|
||||
setDurableClips((prev) => {
|
||||
if (!(index in prev)) return prev;
|
||||
const next = { ...prev };
|
||||
delete next[index];
|
||||
return next;
|
||||
});
|
||||
handleClipStateChange(index, { activeLayers: null, serverVideoFile: newFile });
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,18 @@ const PLATFORM_OPTIONS = [
|
|||
{ value: 'youtube', label: 'youtube', icon: <Youtube size={16} /> },
|
||||
];
|
||||
|
||||
function clipDurationSeconds(clip) {
|
||||
// A recut clip's start/end are the covering source range (segments may be
|
||||
// non-contiguous or reordered); its real duration is the segment sum.
|
||||
const segments = clip.recipe?.segments;
|
||||
if (segments?.length) {
|
||||
return segments.reduce((acc, s) => acc + (s.end - s.start), 0);
|
||||
}
|
||||
return clip.end && clip.start ? clip.end - clip.start : NaN;
|
||||
}
|
||||
|
||||
function formatDuration(clip) {
|
||||
const secs = clip.end && clip.start ? Math.floor(clip.end - clip.start) : NaN;
|
||||
const secs = Math.floor(clipDurationSeconds(clip));
|
||||
if (!Number.isFinite(secs) || secs < 0) return null;
|
||||
return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`;
|
||||
}
|
||||
|
|
@ -126,7 +136,10 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
|||
const [showTranslateModal, setShowTranslateModal] = useState(false);
|
||||
const [editError, setEditError] = useState(null);
|
||||
|
||||
const [clipDuration, setClipDuration] = useState(clip.end && clip.start ? clip.end - clip.start : 30);
|
||||
const [clipDuration, setClipDuration] = useState(() => {
|
||||
const secs = clipDurationSeconds(clip);
|
||||
return Number.isFinite(secs) ? secs : 30;
|
||||
});
|
||||
|
||||
// Accumulate Remotion layers across operations. A reopened project restores
|
||||
// the layers persisted in its project state, so the next edit composes over
|
||||
|
|
|
|||
Loading…
Reference in a new issue