mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-12 07:09:59 +00:00
Revert "feat: Persist Studio manual edits via manifest (#593)"
This reverts commit d0abe90a82.
This commit is contained in:
@@ -89,6 +89,7 @@ export const NLELayout = memo(function NLELayout({
|
||||
togglePlay,
|
||||
seek,
|
||||
onIframeLoad: baseOnIframeLoad,
|
||||
refreshPlayer,
|
||||
saveSeekPosition,
|
||||
} = useTimelinePlayer();
|
||||
|
||||
@@ -102,15 +103,13 @@ export const NLELayout = memo(function NLELayout({
|
||||
usePlayerStore.getState().reset();
|
||||
}
|
||||
|
||||
// Save seek position before the Player component creates a new player
|
||||
// on refreshKey change. The Player handles the actual reload via the
|
||||
// dual-player crossfade; we just need to persist the current time.
|
||||
// Refresh the existing iframe in place when source files change.
|
||||
const prevRefreshKeyRef = useRef(refreshKey);
|
||||
useEffect(() => {
|
||||
if (refreshKey === prevRefreshKeyRef.current) return;
|
||||
prevRefreshKeyRef.current = refreshKey;
|
||||
saveSeekPosition();
|
||||
}, [refreshKey, saveSeekPosition]);
|
||||
refreshPlayer();
|
||||
}, [refreshKey, refreshPlayer]);
|
||||
|
||||
// Wrap onIframeLoad to also notify parent of iframe ref
|
||||
const onIframeLoad = useCallback(() => {
|
||||
@@ -210,10 +209,6 @@ export const NLELayout = memo(function NLELayout({
|
||||
const currentLevel = compositionStack[compositionStack.length - 1];
|
||||
const directUrl = compositionStack.length > 1 ? currentLevel.previewUrl : undefined;
|
||||
|
||||
useEffect(() => {
|
||||
onIframeRef?.(iframeRef.current);
|
||||
}, [compositionStack.length, onIframeRef, refreshKey, iframeRef]);
|
||||
|
||||
// Save master seek position before drilling down so we can restore it on back-navigation.
|
||||
// saveSeekPosition() sets pendingSeekRef in useTimelinePlayer which onIframeLoad reads.
|
||||
const masterSeekRef = useRef(0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { memo, useRef, useState, type Ref } from "react";
|
||||
import { memo, type Ref } from "react";
|
||||
import { Player } from "../../player";
|
||||
|
||||
interface NLEPreviewProps {
|
||||
@@ -21,17 +21,6 @@ export function getPreviewPlayerKey({
|
||||
return directUrl ?? projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages the composition preview with crossfade on reload.
|
||||
*
|
||||
* When refreshKey changes, a new Player is mounted alongside the old one.
|
||||
* The old Player stays visible (opacity 1) until the new one fires onLoad,
|
||||
* at which point the old is removed. This avoids the flash that a simple
|
||||
* key-swap remount would cause.
|
||||
*
|
||||
* Uses the render-time state adjustment pattern (React-sanctioned) to detect
|
||||
* refreshKey changes — no useEffect needed.
|
||||
*/
|
||||
export const NLEPreview = memo(function NLEPreview({
|
||||
projectId,
|
||||
iframeRef,
|
||||
@@ -40,56 +29,22 @@ export const NLEPreview = memo(function NLEPreview({
|
||||
directUrl,
|
||||
refreshKey,
|
||||
}: NLEPreviewProps) {
|
||||
const baseKey = getPreviewPlayerKey({ projectId, directUrl, refreshKey });
|
||||
const prevRefreshKeyRef = useRef(refreshKey);
|
||||
const [retiringKey, setRetiringKey] = useState<string | null>(null);
|
||||
const retiringTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
// Detect refreshKey change during render (React-sanctioned derived state pattern).
|
||||
// When the key changes, the current active player becomes the retiring player
|
||||
// and a new active player is mounted alongside it.
|
||||
if (refreshKey !== prevRefreshKeyRef.current) {
|
||||
const oldKey = `${baseKey}:${prevRefreshKeyRef.current ?? 0}`;
|
||||
prevRefreshKeyRef.current = refreshKey;
|
||||
setRetiringKey(oldKey);
|
||||
}
|
||||
|
||||
const activeKey = `${baseKey}:${refreshKey ?? 0}`;
|
||||
|
||||
const handleNewPlayerLoad = () => {
|
||||
onIframeLoad();
|
||||
if (retiringTimerRef.current) clearTimeout(retiringTimerRef.current);
|
||||
retiringTimerRef.current = setTimeout(() => {
|
||||
setRetiringKey(null);
|
||||
retiringTimerRef.current = null;
|
||||
}, 160);
|
||||
};
|
||||
const playerKey = getPreviewPlayerKey({ projectId, directUrl, refreshKey });
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full min-h-0">
|
||||
<div
|
||||
className="relative flex-1 flex items-center justify-center p-2 overflow-hidden min-h-0 outline-none focus:ring-1 focus:ring-studio-accent/40"
|
||||
className="flex-1 flex items-center justify-center p-2 overflow-hidden min-h-0 outline-none focus:ring-1 focus:ring-studio-accent/40"
|
||||
tabIndex={0}
|
||||
aria-label="Composition preview"
|
||||
>
|
||||
{retiringKey && (
|
||||
<Player
|
||||
key={retiringKey}
|
||||
projectId={directUrl ? undefined : projectId}
|
||||
directUrl={directUrl}
|
||||
onLoad={() => {}}
|
||||
portrait={portrait}
|
||||
style={{ position: "absolute", inset: 0, zIndex: 0, opacity: 1 }}
|
||||
/>
|
||||
)}
|
||||
<Player
|
||||
key={activeKey}
|
||||
key={playerKey}
|
||||
ref={iframeRef}
|
||||
projectId={directUrl ? undefined : projectId}
|
||||
directUrl={directUrl}
|
||||
onLoad={retiringKey ? handleNewPlayerLoad : onIframeLoad}
|
||||
onLoad={onIframeLoad}
|
||||
portrait={portrait}
|
||||
style={retiringKey ? { position: "absolute", inset: 0, zIndex: 1 } : undefined}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user