@@ -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 >
0 commit comments