mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-15 05:46:40 +00:00
fix: caption init race condition, auto-save, and panel auto-open
- Remove store reset from useEffect cleanup — was wiping state on dep changes and breaking auto-save subscription - Move panel auto-open into useEffect instead of during render - Add fallback 500ms poll alongside postMessage listener for initial load Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f2718783c2
commit
614a67dfd3
@@ -139,21 +139,24 @@ export function StudioApp() {
|
||||
};
|
||||
|
||||
window.addEventListener("message", handleMessage);
|
||||
// Also try immediately in case compositions are already loaded
|
||||
// Try immediately in case compositions are already loaded
|
||||
tryActivateCaptions();
|
||||
// Fallback poll — runtime messages can fire before listener is attached on first load
|
||||
const pollId = setInterval(tryActivateCaptions, 500);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("message", handleMessage);
|
||||
if (useCaptionStore.getState().isEditMode) useCaptionStore.getState().reset();
|
||||
clearInterval(pollId);
|
||||
};
|
||||
}, [activeCompPath, projectId]);
|
||||
|
||||
// Auto-expand right panel when a caption word is selected
|
||||
const prevCaptionHasSelection = useRef(false);
|
||||
if (captionEditMode && captionHasSelection && !prevCaptionHasSelection.current && rightCollapsed) {
|
||||
setRightCollapsed(false);
|
||||
}
|
||||
prevCaptionHasSelection.current = captionHasSelection;
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
useEffect(() => {
|
||||
if (captionEditMode && captionHasSelection) {
|
||||
setRightCollapsed(false);
|
||||
}
|
||||
}, [captionHasSelection, captionEditMode]);
|
||||
const [globalDragOver, setGlobalDragOver] = useState(false);
|
||||
const [uploadToast, setUploadToast] = useState<string | null>(null);
|
||||
const [timelineVisible, setTimelineVisible] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user