mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-04 07:19:52 +00:00
refactor(studio): read animation cache keys through their owner
The timeline-element animation lookup rebuilt the three cache-key variants by hand. elementCacheKeys already owns that list for the writers, so this reader takes it from there instead of drifting from it.
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
} from "../../contexts/DomEditContext";
|
} from "../../contexts/DomEditContext";
|
||||||
import { resolveTweenStart, resolveTweenDuration } from "../../utils/globalTimeCompiler";
|
import { resolveTweenStart, resolveTweenDuration } from "../../utils/globalTimeCompiler";
|
||||||
import { resolveClipTimingBasis } from "../../hooks/useGsapTweenCache";
|
import { resolveClipTimingBasis } from "../../hooks/useGsapTweenCache";
|
||||||
|
import { elementCacheKeys } from "../../hooks/gsapKeyframeCacheHelpers";
|
||||||
import { resolveKeyframeRetime } from "../editor/keyframeRetime";
|
import { resolveKeyframeRetime } from "../editor/keyframeRetime";
|
||||||
import type { DomEditSelection } from "../editor/domEditingTypes";
|
import type { DomEditSelection } from "../editor/domEditingTypes";
|
||||||
import type { TimelineMoveOperation } from "../../hooks/timelineMoveAdapter";
|
import type { TimelineMoveOperation } from "../../hooks/timelineMoveAdapter";
|
||||||
@@ -121,12 +122,13 @@ export function useTimelineEditCallbacks({
|
|||||||
const { gsapAnimations } = usePlayerStore.getState();
|
const { gsapAnimations } = usePlayerStore.getState();
|
||||||
const { sourceFile, domId } = splitTimelineElementKey(elementKey);
|
const { sourceFile, domId } = splitTimelineElementKey(elementKey);
|
||||||
const scope = sourceFile ?? activeCompPath ?? "index.html";
|
const scope = sourceFile ?? activeCompPath ?? "index.html";
|
||||||
return (
|
// elementCacheKeys owns the key-variant list the writers use; reading it
|
||||||
gsapAnimations.get(`${scope}#${domId}`) ??
|
// back by hand here is how the two sides drift.
|
||||||
gsapAnimations.get(`index.html#${domId}`) ??
|
for (const key of elementCacheKeys(scope, domId)) {
|
||||||
gsapAnimations.get(domId) ??
|
const animations = gsapAnimations.get(key);
|
||||||
[]
|
if (animations) return animations;
|
||||||
);
|
}
|
||||||
|
return [];
|
||||||
},
|
},
|
||||||
[activeCompPath],
|
[activeCompPath],
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ export function clearKeyframeCacheForFile(sourceFile: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function elementCacheKeys(sourceFile: string, elementId: string): string[] {
|
/** Every cache key a write for this element sets, in read-preference order. */
|
||||||
|
export function elementCacheKeys(sourceFile: string, elementId: string): string[] {
|
||||||
return sourceFile === "index.html"
|
return sourceFile === "index.html"
|
||||||
? [`index.html#${elementId}`, elementId]
|
? [`index.html#${elementId}`, elementId]
|
||||||
: [`${sourceFile}#${elementId}`, `index.html#${elementId}`, elementId];
|
: [`${sourceFile}#${elementId}`, `index.html#${elementId}`, elementId];
|
||||||
|
|||||||
Reference in New Issue
Block a user