fix(ui): pristine preview base + sync cards after bulk subtitles
Two bugs, one root cause: the Remotion preview base was derived from clip.video_url, which mutates to subtitled_/hook_ files after server burns. - originalVideoUrl now strips subtitled_<ts>_/hook_ prefixes back to the pristine clip, so the preview composites new subtitles over the clean clip instead of stacking them on an already-subtitled file (the 'subtitles on top for a few seconds' double-render when opening another clip's modal). - currentVideoUrl inits to the actual current file (not pristine), and a new effect adopts clip.video_url when an external refresh (bulk apply from another card) changes it — so every card shows its freshly subtitled video instead of a stale/blank one.
This commit is contained in:
parent
7162667bbf
commit
80a3e2fda7
1 changed files with 25 additions and 2 deletions
|
|
@ -27,8 +27,17 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
const [showSubtitleModal, setShowSubtitleModal] = useState(false);
|
||||||
const videoRef = React.useRef(null);
|
const videoRef = React.useRef(null);
|
||||||
const originalVideoUrl = getApiUrl(clip.video_url); // Never changes — used for Remotion previews
|
// Pristine base clip (no burned subtitles/hook), stable regardless of how
|
||||||
const [currentVideoUrl, setCurrentVideoUrl] = useState(originalVideoUrl);
|
// clip.video_url mutates after server edits. Used as the compositing base
|
||||||
|
// for the Remotion preview so it never stacks subtitles over an already-
|
||||||
|
// subtitled file (double-subtitle bug).
|
||||||
|
const stripBurns = (filename) => {
|
||||||
|
let f = filename || '', prev;
|
||||||
|
do { prev = f; f = f.replace(/^subtitled_\d+_/, '').replace(/^hook_/, ''); } while (f !== prev);
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
const originalVideoUrl = getApiUrl((clip.video_url || '').replace(/[^/]+$/, stripBurns((clip.video_url || '').split('/').pop())));
|
||||||
|
const [currentVideoUrl, setCurrentVideoUrl] = useState(getApiUrl(clip.video_url));
|
||||||
// Latest file that exists ON THE SERVER (blob: previews don't count).
|
// Latest file that exists ON THE SERVER (blob: previews don't count).
|
||||||
// All server-side operations must chain from this, so burned-in edits
|
// All server-side operations must chain from this, so burned-in edits
|
||||||
// (subtitles, hooks, effects) never get silently dropped.
|
// (subtitles, hooks, effects) never get silently dropped.
|
||||||
|
|
@ -44,6 +53,20 @@ export default function ResultCard({ clip, index, jobId, durableUrl, uploadPostK
|
||||||
}
|
}
|
||||||
}, [videoErrored, durableUrl, currentVideoUrl]);
|
}, [videoErrored, durableUrl, currentVideoUrl]);
|
||||||
|
|
||||||
|
// When an external refresh changes this clip's server file (e.g. bulk
|
||||||
|
// subtitles applied from another card), adopt it so the card shows the
|
||||||
|
// freshly subtitled video instead of a stale one.
|
||||||
|
useEffect(() => {
|
||||||
|
const serverUrl = getApiUrl(clip.video_url);
|
||||||
|
const serverName = (clip.video_url || '').split('/').pop();
|
||||||
|
if (serverName && serverName !== serverVideoFile) {
|
||||||
|
setServerVideoFile(serverName);
|
||||||
|
setCurrentVideoUrl(serverUrl);
|
||||||
|
if (videoRef.current) videoRef.current.load();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [clip.video_url]);
|
||||||
|
|
||||||
const [platforms, setPlatforms] = useState({
|
const [platforms, setPlatforms] = useState({
|
||||||
tiktok: true,
|
tiktok: true,
|
||||||
instagram: true,
|
instagram: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue