Skip to content

Commit f5590cf

Browse files
Merge pull request #1726 from MinitJain/fix/captions-trim-overflow
fix(editor): clamp captions and hide keyboard segments past trim boundary
2 parents 49ff1d7 + 34f7994 commit f5590cf

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

apps/desktop/src-tauri/src/permissions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ pub(crate) fn schedule_macos_dock_visibility_sync(app: &tauri::AppHandle) {
211211

212212
#[cfg(target_os = "macos")]
213213
fn macos_permission_status(permission: &OSPermission, initial_check: bool) -> OSPermissionStatus {
214+
#[cfg(debug_assertions)]
215+
if matches!(
216+
permission,
217+
OSPermission::ScreenRecording | OSPermission::Accessibility
218+
) {
219+
return OSPermissionStatus::Granted;
220+
}
221+
214222
match permission {
215223
OSPermission::ScreenRecording => {
216224
let granted = scap_screencapturekit::has_permission();

apps/desktop/src/routes/editor/Timeline/CaptionsTrack.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export function CaptionsTrack(props: {
3434
const minDuration = () =>
3535
Math.max(MIN_SEGMENT_SECS, secsPerPixel() * MIN_SEGMENT_PIXELS);
3636

37-
const captionSegments = () => project.timeline?.captionSegments ?? [];
37+
const captionSegments = createMemo(() =>
38+
(project.timeline?.captionSegments ?? []).filter(
39+
(s) => s.start < totalDuration(),
40+
),
41+
);
3842
const selectedCaptionIndices = createMemo(() => {
3943
const selection = editorState.timeline.selection;
4044
if (!selection || selection.type !== "caption") return null;
@@ -157,7 +161,8 @@ export function CaptionsTrack(props: {
157161
return indices.has(i());
158162
});
159163

160-
const segmentWidth = () => segment.end - segment.start;
164+
const segmentWidth = () =>
165+
Math.min(segment.end, totalDuration()) - segment.start;
161166

162167
return (
163168
<SegmentRoot
@@ -169,7 +174,10 @@ export function CaptionsTrack(props: {
169174
isSelected() ? "border-green-7" : "border-transparent",
170175
)}
171176
innerClass="ring-green-6"
172-
segment={segment}
177+
segment={{
178+
start: segment.start,
179+
end: Math.min(segment.end, totalDuration()),
180+
}}
173181
onMouseDown={(e) => {
174182
e.stopPropagation();
175183
if (editorState.timeline.interactMode === "split") {

apps/desktop/src/routes/editor/Timeline/KeyboardTrack.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export function KeyboardTrack(props: {
3232
const minDuration = () =>
3333
Math.max(MIN_SEGMENT_SECS, secsPerPixel() * MIN_SEGMENT_PIXELS);
3434

35-
const keyboardSegments = () => project.timeline?.keyboardSegments ?? [];
35+
const keyboardSegments = createMemo(() =>
36+
(project.timeline?.keyboardSegments ?? []).filter(
37+
(s) => s.start < totalDuration(),
38+
),
39+
);
3640
const selectedKeyboardIndices = createMemo(() => {
3741
const selection = editorState.timeline.selection;
3842
if (!selection || selection.type !== "keyboard") return null;
@@ -149,7 +153,8 @@ export function KeyboardTrack(props: {
149153
return indices.has(i());
150154
});
151155

152-
const segmentWidth = () => segment.end - segment.start;
156+
const segmentWidth = () =>
157+
Math.min(segment.end, totalDuration()) - segment.start;
153158

154159
return (
155160
<SegmentRoot
@@ -161,7 +166,10 @@ export function KeyboardTrack(props: {
161166
isSelected() ? "border-sky-7" : "border-transparent",
162167
)}
163168
innerClass="ring-sky-6"
164-
segment={segment}
169+
segment={{
170+
start: segment.start,
171+
end: Math.min(segment.end, totalDuration()),
172+
}}
165173
onMouseDown={(e) => {
166174
e.stopPropagation();
167175
if (editorState.timeline.interactMode === "split") {

0 commit comments

Comments
 (0)