@@ -253,6 +253,7 @@ interface DirFilterRowProps extends FiltersProps {
253253 dir : Directory ,
254254 expandedReducer : ( { verb, value } : { verb : "add" | "remove" , value : string } ) => void ,
255255 showSize : boolean ,
256+ hideSubDirTorrents : boolean ,
256257 selectAllOnDbClk : boolean ,
257258}
258259
@@ -263,6 +264,12 @@ function DirFilterRow(props: DirFilterRowProps) {
263264 return path . startsWith ( props . dir . path ) ;
264265 } , [ props . dir . path ] ) ;
265266
267+ const filterHideSub = useCallback ( ( t : Torrent ) => {
268+ const path = t . downloadDir as string ;
269+ if ( path . length + 1 === props . dir . path . length || path . length === props . dir . path . length ) return props . dir . path . startsWith ( path ) ;
270+ return false ;
271+ } , [ props . dir . path ] ) ;
272+
266273 const onExpand = useCallback ( ( e : React . MouseEvent ) => {
267274 e . stopPropagation ( ) ;
268275 props . dir . expanded = true ;
@@ -309,7 +316,7 @@ function DirFilterRow(props: DirFilterRowProps) {
309316 onClick = { ( event ) => {
310317 props . setCurrentFilters ( {
311318 verb : eventHasModKey ( event ) ? "toggle" : "set" ,
312- filter : { id : props . id , filter } ,
319+ filter : { id : props . id , filter : props . hideSubDirTorrents ? filterHideSub : filter } ,
313320 } ) ;
314321 props . setSearchTracker ( "" ) ;
315322 } }
@@ -498,17 +505,19 @@ export const Filters = React.memo(function Filters({ torrents, currentFilters, s
498505 const [ sectionsMap , setSectionsMap ] = useState ( getSectionsMap ( sections ) ) ;
499506 const [ statusFiltersVisibility , setStatusFiltersVisibility ] = useState ( config . values . interface . statusFiltersVisibility ) ;
500507 const [ compactDirectories , setCompactDirectories ] = useState ( config . values . interface . compactDirectories ) ;
508+ const [ hideSubDirTorrents , setHideSubDirTorrents ] = useState ( config . values . interface . hideSubDirTorrents ) ;
501509 const [ showFilterGroupSize , setShowFilterGroupSize ] = useState ( config . values . interface . showFilterGroupSize ) ;
502510 const [ selectFilterGroupOnDbClk , setSelectFilterGroupOnDbClk ] = useState ( config . values . interface . selectFilterGroupOnDbClk ) ;
503511
504512 useEffect ( ( ) => {
505513 config . values . interface . filterSections = sections ;
506514 config . values . interface . statusFiltersVisibility = statusFiltersVisibility ;
507515 config . values . interface . compactDirectories = compactDirectories ;
516+ config . values . interface . hideSubDirTorrents = hideSubDirTorrents ;
508517 config . values . interface . showFilterGroupSize = showFilterGroupSize ;
509518 config . values . interface . selectFilterGroupOnDbClk = selectFilterGroupOnDbClk ;
510519 setSectionsMap ( getSectionsMap ( sections ) ) ;
511- } , [ config , sections , statusFiltersVisibility , compactDirectories , showFilterGroupSize , selectFilterGroupOnDbClk ] ) ;
520+ } , [ config , sections , statusFiltersVisibility , compactDirectories , hideSubDirTorrents , showFilterGroupSize , selectFilterGroupOnDbClk ] ) ;
512521
513522 const [ info , setInfo , handler ] = useContextMenu ( ) ;
514523
@@ -546,17 +555,22 @@ export const Filters = React.memo(function Filters({ torrents, currentFilters, s
546555 const onCompactDirectoriesClick = useCallback ( ( e : React . MouseEvent ) => {
547556 e . stopPropagation ( ) ;
548557 setCompactDirectories ( ! compactDirectories ) ;
549- } , [ compactDirectories ] ) ;
558+ } , [ setCompactDirectories , compactDirectories ] ) ;
559+
560+ const onHideSubDirTorrentsClick = useCallback ( ( e : React . MouseEvent ) => {
561+ e . stopPropagation ( ) ;
562+ setHideSubDirTorrents ( ! hideSubDirTorrents ) ;
563+ } , [ setHideSubDirTorrents , hideSubDirTorrents ] ) ;
550564
551565 const onShowFilterGroupSizeClick = useCallback ( ( e : React . MouseEvent ) => {
552566 e . stopPropagation ( ) ;
553567 setShowFilterGroupSize ( ! showFilterGroupSize ) ;
554- } , [ showFilterGroupSize ] ) ;
568+ } , [ setShowFilterGroupSize , showFilterGroupSize ] ) ;
555569
556570 const onSelectFilterGroupOnDbClkClick = useCallback ( ( e : React . MouseEvent ) => {
557571 e . stopPropagation ( ) ;
558572 setSelectFilterGroupOnDbClk ( ! selectFilterGroupOnDbClk ) ;
559- } , [ selectFilterGroupOnDbClk ] ) ;
573+ } , [ setSelectFilterGroupOnDbClk , selectFilterGroupOnDbClk ] ) ;
560574
561575 return ( < >
562576 < Menu
@@ -642,6 +656,13 @@ export const Filters = React.memo(function Filters({ torrents, currentFilters, s
642656 >
643657 目录简洁展示
644658 </ Menu . Item >
659+ < Menu . Item
660+ icon = { hideSubDirTorrents ? < Icon . Check size = "1rem" /> : < Box miw = "1rem" /> }
661+ onMouseEnter = { closeStatusFiltersSubmenu }
662+ onMouseDown = { onHideSubDirTorrentsClick }
663+ >
664+ 列表不显示子目录种子
665+ </ Menu . Item >
645666 < Menu . Item
646667 icon = { showFilterGroupSize ? < Icon . Check size = "1rem" /> : < Box miw = "1rem" /> }
647668 onMouseEnter = { closeStatusFiltersSubmenu }
@@ -703,7 +724,7 @@ export const Filters = React.memo(function Filters({ torrents, currentFilters, s
703724 < Divider mx = "sm" mt = "md" label = "数据目录" labelPosition = "center" />
704725 { dirs . map ( ( d ) =>
705726 < DirFilterRow key = { `dir-${ d . path } ` } id = { `dir-${ d . path } ` }
706- showSize = { showFilterGroupSize } selectAllOnDbClk = { selectFilterGroupOnDbClk }
727+ showSize = { showFilterGroupSize } hideSubDirTorrents = { hideSubDirTorrents } selectAllOnDbClk = { selectFilterGroupOnDbClk }
707728 dir = { d } expandedReducer = { expandedReducer } { ...{ torrents, currentFilters, setCurrentFilters, setSearchTracker, setCurrentTorrentId, selectedReducer } } /> ) }
708729 </ div > }
709730 { sections [ sectionsMap [ "用户标签" ] ] ?. visible && < div style = { { order : sectionsMap [ "用户标签" ] } } >
0 commit comments