diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-04-26 17:31:28 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-04-26 17:31:28 +0200 |
| commit | 56ca09692a308b22455420d11376ff8d41244c47 (patch) | |
| tree | 4eca5ae032451c5db954801008aa9f164b2e2b1d /apps/web/src/components/editable-timecode.tsx | |
| parent | e6c6193638e4247ff1e6f2df40de2a057112c773 (diff) | |
| download | opencut-56ca09692a308b22455420d11376ff8d41244c47.tar.gz | |
refactor: thinner hooks
Diffstat (limited to 'apps/web/src/components/editable-timecode.tsx')
| -rw-r--r-- | apps/web/src/components/editable-timecode.tsx | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/apps/web/src/components/editable-timecode.tsx b/apps/web/src/components/editable-timecode.tsx index 8450cec2..aaae79a9 100644 --- a/apps/web/src/components/editable-timecode.tsx +++ b/apps/web/src/components/editable-timecode.tsx @@ -1,9 +1,17 @@ "use client"; import { useEffect, useRef, useState } from "react"; -import { formatTimecode, parseTimecode, snappedSeekTime, type FrameRate, type TimeCodeFormat } from "opencut-wasm"; +import { + formatTimecode, + type FrameRate, + type TimeCodeFormat, +} from "opencut-wasm"; import { cn } from "@/utils/ui"; -import type { MediaTime } from "@/wasm"; +import { + parseMediaTimecode, + snapSeekMediaTime, + type MediaTime, +} from "@/wasm"; interface EditableTimecodeProps { time: MediaTime; @@ -47,19 +55,20 @@ export function EditableTimecode({ }; const applyEdit = () => { - const parsedTime = parseTimecode({ timeCode: inputValue, format, rate: fps }); + const parsedTime = parseMediaTimecode({ + timeCode: inputValue, + format, + fps, + }); if (parsedTime == null) { setHasError(true); return; } - const clampedTime = ( - duration - ? (snappedSeekTime({ time: parsedTime, duration, rate: fps }) ?? - parsedTime) - : parsedTime - ) as MediaTime; + const clampedTime = duration + ? snapSeekMediaTime({ time: parsedTime, duration, fps }) + : parsedTime; onTimeChange?.({ time: clampedTime }); setIsEditing(false); |
