@@ -96,8 +96,14 @@ function NameField(props: TableFieldProps) {
9696
9797 const rpcVersion = useServerRpcVersion ( ) ;
9898
99+ const onArrowLeftRight = useCallback ( ( key : string ) => {
100+ if ( props . row . subRows . length === 0 ) return ;
101+ if ( key === "ArrowLeft" && props . row . getIsExpanded ( ) ) props . row . toggleExpanded ( ) ;
102+ if ( key === "ArrowRight" && ! props . row . getIsExpanded ( ) ) props . row . toggleExpanded ( ) ;
103+ } , [ props . row ] ) ;
104+
99105 return (
100- < EditableNameField currentName = { props . entry . name }
106+ < EditableNameField currentName = { props . entry . name } onArrowLeftRight = { onArrowLeftRight }
101107 onUpdate = { ( props . treeName === "filetree" && rpcVersion >= 15 ) ? updatePath : undefined } >
102108 < Box sx = { { width : `${ props . entry . level * 1.6 } rem` , flexShrink : 0 } } />
103109 < Box w = "1.4rem" mx = "auto" sx = { { flexShrink : 0 } } >
@@ -282,9 +288,7 @@ export function FileTreeTable(props: FileTreeTableProps) {
282288 } ) , [ props . brief , props . fileTree , nameSortFunc , onCheckboxChange ] ) ;
283289
284290 const getRowId = useCallback ( ( row : FileDirEntryView ) => row . fullpath , [ ] ) ;
285- const getSubRows = useCallback ( ( row : FileDirEntryView ) => {
286- return row . subrows ;
287- } , [ ] ) ;
291+ const getSubRows = useCallback ( ( row : FileDirEntryView ) => row . subrows , [ ] ) ;
288292
289293 const { selected, selectedReducer } = useSelected ( props ) ;
290294
@@ -412,7 +416,7 @@ function FiletreeContextMenu(props: {
412416 onEntryOpen ( rowPath , reveal ) ;
413417 } , [ onEntryOpen , props . fileTree , props . selected ] ) ;
414418
415- const mutation = useMutateTorrent ( ) ;
419+ const { mutate } = useMutateTorrent ( ) ;
416420
417421 const setPriority = useCallback ( ( priority : "priority-high" | "priority-normal" | "priority-low" ) => {
418422 const fileIds = Array . from ( props . selected
@@ -422,7 +426,7 @@ function FiletreeContextMenu(props: {
422426 return set ;
423427 } , new Set < number > ( ) ) ) ;
424428
425- mutation . mutate (
429+ mutate (
426430 {
427431 torrentIds : [ props . fileTree . torrentId ] ,
428432 fields : {
@@ -438,7 +442,7 @@ function FiletreeContextMenu(props: {
438442 } ,
439443 } ,
440444 ) ;
441- } , [ mutation , props . fileTree , props . selected ] ) ;
445+ } , [ mutate , props . fileTree , props . selected ] ) ;
442446
443447 const setWanted = useCallback ( ( wanted : boolean ) => {
444448 const fileIds = Array . from ( props . selected
@@ -448,7 +452,7 @@ function FiletreeContextMenu(props: {
448452 return set ;
449453 } , new Set < number > ( ) ) ) ;
450454
451- mutation . mutate (
455+ mutate (
452456 {
453457 torrentIds : [ props . fileTree . torrentId ] ,
454458 fields : {
@@ -464,7 +468,7 @@ function FiletreeContextMenu(props: {
464468 } ,
465469 } ,
466470 ) ;
467- } , [ mutation , props . fileTree , props . selected ] ) ;
471+ } , [ mutate , props . fileTree , props . selected ] ) ;
468472
469473 return (
470474 < ContextMenu contextMenuInfo = { props . contextMenuInfo } setContextMenuInfo = { props . setContextMenuInfo } >
0 commit comments