Skip to content

Commit 2a153d0

Browse files
committed
cleanup
1 parent 380bad1 commit 2a153d0

File tree

7 files changed

+200
-148
lines changed

7 files changed

+200
-148
lines changed

apps/desktop/src/routes/(window-chrome)/settings/recordings.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,16 @@ function RecordingItem(props: {
223223
return (
224224
<li
225225
onClick={() => {
226-
props.onOpenEditor();
226+
if (mode() === "studio") {
227+
props.onOpenEditor();
228+
}
227229
}}
228-
class="flex flex-row justify-between p-3 [&:not(:last-child)]:border-b [&:not(:last-child)]:border-gray-3 items-center w-full transition-colors duration-200 hover:bg-gray-3"
230+
class={cx(
231+
"flex flex-row justify-between p-3 [&:not(:last-child)]:border-b [&:not(:last-child)]:border-gray-3 items-center w-full transition-colors duration-200",
232+
mode() === "studio"
233+
? "cursor-pointer hover:bg-gray-3"
234+
: "cursor-default",
235+
)}
229236
>
230237
<div class="flex gap-5 items-center">
231238
<Show

apps/desktop/src/routes/editor/ConfigSidebar.tsx

Lines changed: 98 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -734,121 +734,130 @@ export function ConfigSidebar() {
734734
const sceneSelection = selection();
735735
if (sceneSelection.type !== "scene") return;
736736

737-
const segment =
738-
project.timeline?.sceneSegments?.[sceneSelection.index];
739-
if (!segment) return;
737+
const segments = sceneSelection.indices
738+
.map((idx) => ({
739+
segment: project.timeline?.sceneSegments?.[idx],
740+
index: idx,
741+
}))
742+
.filter((s) => s.segment !== undefined);
740743

741-
return { selection: sceneSelection, segment };
744+
if (segments.length === 0) return;
745+
return { selection: sceneSelection, segments };
742746
})()}
743747
>
744748
{(value) => (
745-
<SceneSegmentConfig
746-
segment={value().segment}
747-
segmentIndex={value().selection.index}
748-
/>
749+
<Show
750+
when={value().segments.length > 1}
751+
fallback={
752+
<SceneSegmentConfig
753+
segment={value().segments[0].segment!}
754+
segmentIndex={value().segments[0].index}
755+
/>
756+
}
757+
>
758+
<div class="space-y-4">
759+
<div class="flex flex-row justify-between items-center">
760+
<div class="flex gap-2 items-center">
761+
<EditorButton
762+
onClick={() =>
763+
setEditorState("timeline", "selection", null)
764+
}
765+
leftIcon={<IconLucideCheck />}
766+
>
767+
Done
768+
</EditorButton>
769+
<span class="text-sm text-gray-10">
770+
{value().segments.length} scene{" "}
771+
{value().segments.length === 1
772+
? "segment"
773+
: "segments"}{" "}
774+
selected
775+
</span>
776+
</div>
777+
<EditorButton
778+
variant="danger"
779+
onClick={() => {
780+
const indices = value().selection.indices;
781+
782+
// Delete segments in reverse order to maintain indices
783+
[...indices]
784+
.sort((a, b) => b - a)
785+
.forEach((idx) => {
786+
projectActions.deleteSceneSegment(idx);
787+
});
788+
}}
789+
leftIcon={<IconCapTrash />}
790+
>
791+
Delete
792+
</EditorButton>
793+
</div>
794+
</div>
795+
</Show>
749796
)}
750797
</Show>
751798
<Show
752799
when={(() => {
753800
const clipSelection = selection();
754801
if (clipSelection.type !== "clip") return;
755802

756-
// Handle multiple clip selection
757-
if (Array.isArray(clipSelection.index)) {
758-
const segments = clipSelection.index
759-
.map((idx) => ({
760-
segment: project.timeline?.segments?.[idx],
761-
index: idx,
762-
}))
763-
.filter((s) => s.segment !== undefined);
764-
765-
if (segments.length === 0) return;
766-
return { selection: clipSelection, segments };
767-
}
768-
769-
// Handle single clip selection
770-
const segment =
771-
project.timeline?.segments?.[clipSelection.index];
772-
if (!segment) return;
803+
const segments = clipSelection.indices
804+
.map((idx) => ({
805+
segment: project.timeline?.segments?.[idx],
806+
index: idx,
807+
}))
808+
.filter((s) => s.segment !== undefined);
773809

774-
return { selection: clipSelection, segment };
810+
if (segments.length === 0) return;
811+
return { selection: clipSelection, segments };
775812
})()}
776813
>
777814
{(value) => (
778815
<Show
779-
when={(() => {
780-
const v = value();
781-
if ("segments" in v && Array.isArray(v.segments)) {
782-
return v as {
783-
selection: { type: "clip"; index: number[] };
784-
segments: Array<{
785-
segment: TimelineSegment | undefined;
786-
index: number;
787-
}>;
788-
};
789-
}
790-
return undefined;
791-
})()}
816+
when={value().segments.length > 1}
792817
fallback={
793818
<ClipSegmentConfig
794-
segment={
795-
(
796-
value() as {
797-
selection: { type: "clip"; index: number };
798-
segment: TimelineSegment;
799-
}
800-
).segment
801-
}
802-
segmentIndex={
803-
(
804-
value() as {
805-
selection: { type: "clip"; index: number };
806-
segment: TimelineSegment;
807-
}
808-
).selection.index
809-
}
819+
segment={value().segments[0].segment!}
820+
segmentIndex={value().segments[0].index}
810821
/>
811822
}
812823
>
813-
{(multiValue) => (
814-
<div class="space-y-4">
815-
<div class="flex flex-row justify-between items-center">
816-
<div class="flex gap-2 items-center">
817-
<EditorButton
818-
onClick={() =>
819-
setEditorState("timeline", "selection", null)
820-
}
821-
leftIcon={<IconLucideCheck />}
822-
>
823-
Done
824-
</EditorButton>
825-
<span class="text-sm text-gray-10">
826-
{multiValue().segments.length} clip{" "}
827-
{multiValue().segments.length === 1
828-
? "segment"
829-
: "segments"}{" "}
830-
selected
831-
</span>
832-
</div>
824+
<div class="space-y-4">
825+
<div class="flex flex-row justify-between items-center">
826+
<div class="flex gap-2 items-center">
833827
<EditorButton
834-
variant="danger"
835-
onClick={() => {
836-
const indices = multiValue().selection.index;
837-
838-
// Delete segments in reverse order to maintain indices
839-
[...indices]
840-
.sort((a, b) => b - a)
841-
.forEach((idx) => {
842-
projectActions.deleteClipSegment(idx);
843-
});
844-
}}
845-
leftIcon={<IconCapTrash />}
828+
onClick={() =>
829+
setEditorState("timeline", "selection", null)
830+
}
831+
leftIcon={<IconLucideCheck />}
846832
>
847-
Delete
833+
Done
848834
</EditorButton>
835+
<span class="text-sm text-gray-10">
836+
{value().segments.length} clip{" "}
837+
{value().segments.length === 1
838+
? "segment"
839+
: "segments"}{" "}
840+
selected
841+
</span>
849842
</div>
843+
<EditorButton
844+
variant="danger"
845+
onClick={() => {
846+
const indices = value().selection.indices;
847+
848+
// Delete segments in reverse order to maintain indices
849+
[...indices]
850+
.sort((a, b) => b - a)
851+
.forEach((idx) => {
852+
projectActions.deleteClipSegment(idx);
853+
});
854+
}}
855+
leftIcon={<IconCapTrash />}
856+
>
857+
Delete
858+
</EditorButton>
850859
</div>
851-
)}
860+
</div>
852861
</Show>
853862
)}
854863
</Show>

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

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,7 @@ export function ClipTrack(
244244

245245
if (segmentIndex === undefined || segmentIndex === -1) return false;
246246

247-
// Support both single index and array of indices
248-
if (typeof selection.index === "number") {
249-
return segmentIndex === selection.index;
250-
}
251-
252-
return (
253-
Array.isArray(selection.index) &&
254-
selection.index.includes(segmentIndex)
255-
);
247+
return selection.indices.includes(segmentIndex);
256248
});
257249

258250
const micWaveform = () => {
@@ -403,11 +395,7 @@ export function ClipTrack(
403395
selection.type === "clip"
404396
) {
405397
// Range selection: select from last selected to current
406-
const existingIndices = Array.isArray(
407-
selection.index,
408-
)
409-
? selection.index
410-
: [selection.index];
398+
const existingIndices = selection.indices;
411399
const lastIndex =
412400
existingIndices[existingIndices.length - 1];
413401
const start = Math.min(lastIndex, currentIndex);
@@ -419,21 +407,15 @@ export function ClipTrack(
419407

420408
setEditorState("timeline", "selection", {
421409
type: "clip" as const,
422-
index: (rangeIndices.length === 1
423-
? rangeIndices[0]
424-
: rangeIndices) as number | number[],
410+
indices: rangeIndices,
425411
});
426412
} else if (
427413
isMultiSelect &&
428414
selection &&
429415
selection.type === "clip"
430416
) {
431417
// Multi-select: toggle current index
432-
const existingIndices = Array.isArray(
433-
selection.index,
434-
)
435-
? selection.index
436-
: [selection.index];
418+
const existingIndices = selection.indices;
437419

438420
if (existingIndices.includes(currentIndex)) {
439421
// Remove from selection
@@ -443,31 +425,23 @@ export function ClipTrack(
443425
if (newIndices.length > 0) {
444426
setEditorState("timeline", "selection", {
445427
type: "clip" as const,
446-
index: (newIndices.length === 1
447-
? newIndices[0]
448-
: newIndices) as number | number[],
428+
indices: newIndices,
449429
});
450430
} else {
451431
setEditorState("timeline", "selection", null);
452432
}
453433
} else {
454434
// Add to selection
455-
const newIndices = [
456-
...existingIndices,
457-
currentIndex,
458-
];
459435
setEditorState("timeline", "selection", {
460436
type: "clip" as const,
461-
index: (newIndices.length === 1
462-
? newIndices[0]
463-
: newIndices) as number | number[],
437+
indices: [...existingIndices, currentIndex],
464438
});
465439
}
466440
} else {
467441
// Normal single selection
468442
setEditorState("timeline", "selection", {
469443
type: "clip" as const,
470-
index: currentIndex,
444+
indices: [currentIndex],
471445
});
472446
}
473447

0 commit comments

Comments
 (0)