@@ -579,7 +579,7 @@ public static FilePicker GetRemoteFilePicker(object o, string? searchFilter = nu
579579 public static FilePicker GetFilePicker ( object o , string startingPath , string ? searchFilter = null , bool onlyAllowFolders = false , bool allowMulti = false )
580580 {
581581
582- if ( ! _filePickers . TryGetValue ( o , out FilePicker ? fp )
582+ if ( ! _filePickers . TryGetValue ( o , out FilePicker ? fp )
583583 || ( rgatState . NetworkBridge . ActiveNetworking is true && fp . _remoteMirror is null )
584584 || ( rgatState . NetworkBridge . ActiveNetworking is false && fp . _remoteMirror is not null )
585585 )
@@ -718,8 +718,8 @@ private bool InitCurrentDirInfo(JToken responseTok)
718718 return false ;
719719 }
720720
721- if ( ! response . TryGetValue ( "Parent" , out JToken ? parentTok ) || ( parentTok . Type is not JTokenType . String
722- &&
721+ if ( ! response . TryGetValue ( "Parent" , out JToken ? parentTok ) || ( parentTok . Type is not JTokenType . String
722+ &&
723723 parentTok . Type is not JTokenType . Null ) )
724724 {
725725 return false ;
@@ -755,6 +755,7 @@ private bool InitCurrentDirInfo(JToken responseTok)
755755 {
756756 _sortedDirs = null ;
757757 _sortedFiles = null ;
758+
758759 Data . Contents . RefreshDirectoryContents ( newDirContents . AllPaths ( ) , newDirContents ) ;
759760 }
760761 else
@@ -1386,82 +1387,84 @@ private void SortDisplayFiles(ImGuiTableColumnSortSpecsPtr sortSpecs)
13861387
13871388 private PickerResult DrawDirsFilesList ( )
13881389 {
1389- if ( _sortedDirs is null || _sortedFiles is null )
1390- {
1391- return PickerResult . eNoAction ;
1392- }
1393-
13941390 PickerResult result = PickerResult . eNoAction ;
1395- float longestFilename = 100 ;
1396- foreach ( var path_data in _sortedDirs )
1391+ lock ( _lock )
13971392 {
1398- ImGui . TableNextRow ( ) ;
1399- ImGui . TableNextColumn ( ) ;
1393+ if ( _sortedDirs is null || _sortedFiles is null )
1394+ {
1395+ return PickerResult . eNoAction ;
1396+ }
1397+ float longestFilename = 100 ;
1398+ foreach ( var path_data in _sortedDirs )
1399+ {
1400+ ImGui . TableNextRow ( ) ;
1401+ ImGui . TableNextColumn ( ) ;
14001402
1401- FileMetadata md = path_data . Value ;
1402- string path = path_data . Key ;
1403- ImGui . PushStyleColor ( ImGuiCol . Text , md . ListingColour ( ) ) ;
1404- bool selected = AllowMultiSelect && SelectedDirectories . Contains ( path ) ;
1405- ImGui . Selectable ( $ "{ ImGuiController . FA_ICON_DIRECTORY } { path_data . Value . filename } /", selected , ImGuiSelectableFlags . SpanAllColumns ) ;
1403+ FileMetadata md = path_data . Value ;
1404+ string path = path_data . Key ;
1405+ ImGui . PushStyleColor ( ImGuiCol . Text , md . ListingColour ( ) ) ;
1406+ bool selected = AllowMultiSelect && SelectedDirectories . Contains ( path ) ;
1407+ ImGui . Selectable ( $ "{ ImGuiController . FA_ICON_DIRECTORY } { path_data . Value . filename } /", selected , ImGuiSelectableFlags . SpanAllColumns ) ;
14061408
1407- if ( AllowMultiSelect &&
1408- ( ImGui . IsItemClicked ( ImGuiMouseButton . Right ) ||
1409- ( ImGui . IsItemClicked ( ImGuiMouseButton . Left ) && ImGui . GetIO ( ) . KeyCtrl ) ) )
1410- {
1411- if ( selected )
1409+ if ( AllowMultiSelect &&
1410+ ( ImGui . IsItemClicked ( ImGuiMouseButton . Right ) ||
1411+ ( ImGui . IsItemClicked ( ImGuiMouseButton . Left ) && ImGui . GetIO ( ) . KeyCtrl ) ) )
14121412 {
1413- this . SelectedDirectories . RemoveAll ( x => x == path ) ;
1413+ if ( selected )
1414+ {
1415+ this . SelectedDirectories . RemoveAll ( x => x == path ) ;
1416+ }
1417+ else
1418+ {
1419+ this . SelectedDirectories . Add ( path ) ;
1420+ }
14141421 }
14151422 else
14161423 {
1417- this . SelectedDirectories . Add ( path ) ;
1424+ if ( ImGui . IsItemClicked ( ImGuiMouseButton . Left ) )
1425+ {
1426+ SetActiveDirectory ( path ) ;
1427+ }
14181428 }
1419- }
1420- else
1421- {
1422- if ( ImGui . IsItemClicked ( ImGuiMouseButton . Left ) )
1429+ SmallWidgets . MouseoverText ( "Ctrl-left click or right click to select directories." ) ;
1430+
1431+ if ( path_data . Value . namewidth > longestFilename )
14231432 {
1424- SetActiveDirectory ( path ) ;
1433+ longestFilename = path_data . Value . namewidth ;
14251434 }
1426- }
1427- SmallWidgets . MouseoverText ( "Ctrl-left click or right click to select directories." ) ;
1428-
1429- if ( path_data . Value . namewidth > longestFilename )
1430- {
1431- longestFilename = path_data . Value . namewidth ;
1432- }
14331435
1434- ImGui . TableNextColumn ( ) ;
1435- if ( ImGui . TableNextColumn ( ) )
1436- {
1437- //size
1438- ImGui . Text ( path_data . Value . size_str ) ;
1439- }
1440- if ( ImGui . TableNextColumn ( ) )
1441- {
1442- ImGui . Text ( "" ) ;
1436+ ImGui . TableNextColumn ( ) ;
1437+ if ( ImGui . TableNextColumn ( ) )
1438+ {
1439+ //size
1440+ ImGui . Text ( path_data . Value . size_str ) ;
1441+ }
1442+ if ( ImGui . TableNextColumn ( ) )
1443+ {
1444+ ImGui . Text ( "" ) ;
1445+ }
1446+ ImGui . PopStyleColor ( ) ;
14431447 }
1444- ImGui . PopStyleColor ( ) ;
1445- }
14461448
1447- foreach ( var path_data in _sortedFiles )
1448- {
1449- FileMetadata filemd = path_data . Value ;
1450- if ( EmitFileSelectableEntry ( path : path_data . Key , filemeta : filemd ) )
1451- {
1452- this . SelectedFile = path_data . Key ;
1453- ImGui . CloseCurrentPopup ( ) ;
1454- result = PickerResult . eTrue ;
1455- }
1456- if ( path_data . Value . namewidth > longestFilename )
1449+ foreach ( var path_data in _sortedFiles )
14571450 {
1458- longestFilename = path_data . Value . namewidth ;
1459- }
1451+ FileMetadata filemd = path_data . Value ;
1452+ if ( EmitFileSelectableEntry ( path : path_data . Key , filemeta : filemd ) )
1453+ {
1454+ this . SelectedFile = path_data . Key ;
1455+ ImGui . CloseCurrentPopup ( ) ;
1456+ result = PickerResult . eTrue ;
1457+ }
1458+ if ( path_data . Value . namewidth > longestFilename )
1459+ {
1460+ longestFilename = path_data . Value . namewidth ;
1461+ }
14601462
1461- if ( ImGui . IsItemHovered ( ) && ImGui . IsMouseDoubleClicked ( 0 ) )
1462- {
1463- result = PickerResult . eTrue ;
1464- ImGui . CloseCurrentPopup ( ) ;
1463+ if ( ImGui . IsItemHovered ( ) && ImGui . IsMouseDoubleClicked ( 0 ) )
1464+ {
1465+ result = PickerResult . eTrue ;
1466+ ImGui . CloseCurrentPopup ( ) ;
1467+ }
14651468 }
14661469 }
14671470 return result ;
0 commit comments