@@ -26,8 +26,6 @@ private class State
2626 public float LeftPanelWidth { get ; set ; } = UiConstants . DefaultLeftPanelWidth ;
2727 public bool IsFolderSectionCollapsed { get ; set ; }
2828 public HashSet < string > ExpandedFolders { get ; } = [ ] ;
29- public DateTime LastCacheUpdate { get ; set ; }
30- public Dictionary < string , int > FolderMacroCounts { get ; } = [ ] ;
3129 }
3230
3331 private readonly State _state = new ( ) ;
@@ -80,7 +78,6 @@ private void DrawLeftPanel()
8078
8179 private void DrawMacroTree ( )
8280 {
83- UpdateMacroCache ( ) ;
8481 DrawMacroTreeHeader ( ) ;
8582 if ( ! _state . IsFolderSectionCollapsed )
8683 DrawFolderTree ( ) ;
@@ -158,7 +155,7 @@ private void DrawCustomFolders()
158155 private void DrawFolderNode ( string folderPath )
159156 {
160157 var isSelected = _state . SelectedFolderId == folderPath ;
161- var folderCount = _state . FolderMacroCounts . GetValueOrDefault ( folderPath , 0 ) ;
158+ var folderCount = C . GetMacroCount ( folderPath ) ;
162159
163160 var flags = ImGuiTreeNodeFlags . OpenOnArrow | ImGuiTreeNodeFlags . SpanAvailWidth ;
164161 if ( isSelected ) flags |= ImGuiTreeNodeFlags . Selected ;
@@ -178,7 +175,6 @@ private void DrawFolderNode(string folderPath)
178175 }
179176
180177 DrawFolderContextMenu ( folderPath ) ;
181-
182178 ImGui . Indent ( 10 ) ;
183179 DrawFolderContents ( folderPath ) ;
184180 ImGui . Unindent ( 10 ) ;
@@ -226,18 +222,14 @@ private void DrawFolderContextMenu(string folderPath)
226222
227223 if ( ImGui . MenuItem ( "Delete Folder" ) )
228224 {
229- if ( ShowDeleteFolderConfirmation ( folderPath ) )
225+ try
230226 {
231- try
232- {
233- DeleteFolder ( folderPath ) ;
234- }
235- catch ( Exception ex )
236- {
237- Svc . Log . Error ( ex , "Error deleting folder" ) ;
238- }
227+ DeleteFolder ( folderPath ) ;
228+ }
229+ catch ( Exception ex )
230+ {
231+ Svc . Log . Error ( ex , "Error deleting folder" ) ;
239232 }
240- ImGui . CloseCurrentPopup ( ) ;
241233 }
242234 ImGuiEx . Tooltip ( "Delete this folder and move all macros to root folder" ) ;
243235 }
@@ -254,7 +246,7 @@ private void DrawSearchResults()
254246 if ( folderPath . Contains ( _state . SearchText , StringComparison . OrdinalIgnoreCase ) )
255247 {
256248 foundAnyFolders = true ;
257- var folderCount = _state . FolderMacroCounts . GetValueOrDefault ( folderPath , 0 ) ;
249+ var folderCount = C . GetMacroCount ( folderPath ) ;
258250 var isSelected = _state . SelectedFolderId == folderPath ;
259251
260252 if ( ImGui . Selectable ( $ "📁 { folderPath } ({ folderCount } )", isSelected ) )
@@ -425,56 +417,6 @@ private void HandleMacroContextMenu(ConfigMacro macro)
425417 }
426418 }
427419
428- private void UpdateMacroCache ( )
429- {
430- if ( ( DateTime . Now - _state . LastCacheUpdate ) . TotalSeconds <= 5 ) return ;
431-
432- try
433- {
434- _state . FolderMacroCounts . Clear ( ) ;
435- foreach ( var folderPath in C . GetFolderPaths ( ) . Where ( f => ! string . IsNullOrEmpty ( f ) ) )
436- _state . FolderMacroCounts [ folderPath ] = C . GetMacroCount ( folderPath ) ;
437-
438- _state . LastCacheUpdate = DateTime . Now ;
439- }
440- catch ( Exception ex )
441- {
442- Svc . Log . Error ( ex , "Error updating macro cache" ) ;
443- }
444- }
445-
446- private bool ShowDeleteFolderConfirmation ( string folderPath )
447- {
448- var macroCount = _state . FolderMacroCounts . GetValueOrDefault ( folderPath , 0 ) ;
449- var message = macroCount > 0
450- ? $ "Are you sure you want to delete folder '{ folderPath } ' and move { macroCount } macro(s) to root folder?"
451- : $ "Are you sure you want to delete empty folder '{ folderPath } '?";
452-
453- if ( ImGui . GetIO ( ) . KeyCtrl )
454- return true ;
455-
456- var confirmed = false ;
457- ImGui . OpenPopup ( "Delete Folder" ) ;
458- var isOpen = true ;
459- using var popup = ImRaii . PopupModal ( "Delete Folder" , ref isOpen , ImGuiWindowFlags . AlwaysAutoResize ) ;
460- if ( popup )
461- {
462- ImGui . TextWrapped ( message ) ;
463- ImGui . Separator ( ) ;
464-
465- if ( ImGui . Button ( "Yes" , new Vector2 ( 120 , 0 ) ) )
466- {
467- confirmed = true ;
468- ImGui . CloseCurrentPopup ( ) ;
469- }
470-
471- ImGui . SameLine ( ) ;
472- if ( ImGui . Button ( "No" , new Vector2 ( 120 , 0 ) ) )
473- ImGui . CloseCurrentPopup ( ) ;
474- }
475- return confirmed ;
476- }
477-
478420 private void MoveMacroToFolder ( string macroId , string folderPath )
479421 {
480422 if ( C . GetMacro ( macroId ) is ConfigMacro configMacro )
0 commit comments