Files
hyperframes/packages/studio/src/hooks/useEffectiveTimelineDuration.ts
T
Vance Ingalls 89069d24c3 fix(studio): keep preview state synchronized (#3450)
* fix(core): harden audio FX and group identity

* fix(core): address audio group review feedback

* fix(core): align preview transport with grouped audio

* test(core): pin audio group gain ceiling

* fix(core): preserve solo bridge through stack

* fix(engine): harden grouped audio rendering

* docs(engine): explain grouped mix fallback invariant

* test(engine): allow grouped mixes to finish on Windows

* feat(lint): validate audio group membership and timing

* test(lint): pin audio group membership guards

* fix(studio): unify audio IDs and group state

* fix(studio): make audio-group edits transactional

* fix(studio): keep preview state synchronized
2026-08-23 18:10:46 -07:00

23 lines
994 B
TypeScript

import { useMemo } from "react";
import type { TimelineElement } from "../player/store/timelineElement";
import { getEffectiveTimelineDuration } from "../player/components/timelineViewModel";
/**
* The stored `duration` lags a moment behind an edit that pushes an element
* past it (drag, trim, paste) — this is the actual end of the timeline, the
* later of the stored duration and the furthest element's end.
*/
export function useEffectiveTimelineDuration(
timelineDuration: number,
timelineElements: readonly TimelineElement[],
): number {
// Delegates to `getEffectiveTimelineDuration` rather than restating the
// arithmetic: that one guards a non-finite stored duration and a non-finite
// result (an element with NaN timing), which this copy did not — it would
// return NaN and every downstream width became NaN with it.
return useMemo(
() => getEffectiveTimelineDuration(timelineDuration, timelineElements),
[timelineDuration, timelineElements],
);
}