@@ -397,15 +397,37 @@ await lib.CheckDefaultSaveFolderAccess() &&
397397 }
398398 }
399399
400- section . IsExpanded = Ioc . Default . GetRequiredService < SettingsViewModel > ( ) . Get ( section . Text == "Pinned" . GetLocalizedResource ( ) , $ "section:{ section . Text . Replace ( '\\ ' , '_' ) } ") ;
401400 section . PropertyChanged += Section_PropertyChanged ;
402401 }
403402
404403 private void Section_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
405404 {
406405 if ( sender is LocationItem section && e . PropertyName == nameof ( section . IsExpanded ) )
407406 {
408- Ioc . Default . GetRequiredService < SettingsViewModel > ( ) . Set ( section . IsExpanded , $ "section:{ section . Text . Replace ( '\\ ' , '_' ) } ") ;
407+ switch ( section . Text )
408+ {
409+ case var text when text == "Pinned" . GetLocalizedResource ( ) :
410+ UserSettingsService . GeneralSettingsService . IsPinnedSectionExpanded = section . IsExpanded ;
411+ break ;
412+ case var text when text == "SidebarLibraries" . GetLocalizedResource ( ) :
413+ UserSettingsService . GeneralSettingsService . IsLibrarySectionExpanded = section . IsExpanded ;
414+ break ;
415+ case var text when text == "Drives" . GetLocalizedResource ( ) :
416+ UserSettingsService . GeneralSettingsService . IsDriveSectionExpanded = section . IsExpanded ;
417+ break ;
418+ case var text when text == "SidebarCloudDrives" . GetLocalizedResource ( ) :
419+ UserSettingsService . GeneralSettingsService . IsCloudDriveSectionExpanded = section . IsExpanded ;
420+ break ;
421+ case var text when text == "Network" . GetLocalizedResource ( ) :
422+ UserSettingsService . GeneralSettingsService . IsNetworkSectionExpanded = section . IsExpanded ;
423+ break ;
424+ case var text when text == "WSL" . GetLocalizedResource ( ) :
425+ UserSettingsService . GeneralSettingsService . IsWslSectionExpanded = section . IsExpanded ;
426+ break ;
427+ case var text when text == "FileTags" . GetLocalizedResource ( ) :
428+ UserSettingsService . GeneralSettingsService . IsFileTagsSectionExpanded = section . IsExpanded ;
429+ break ;
430+ }
409431 }
410432 }
411433
@@ -448,6 +470,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
448470 section = BuildSection ( "Pinned" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
449471 icon = new BitmapImage ( new Uri ( Constants . FluentIconsPaths . StarIcon ) ) ;
450472 section . IsHeader = true ;
473+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsPinnedSectionExpanded ;
451474
452475 break ;
453476 }
@@ -461,6 +484,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
461484 section = BuildSection ( "SidebarLibraries" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { IsLibrariesHeader = true , ShowHideSection = true } , false ) ;
462485 iconIdex = Constants . ImageRes . Libraries ;
463486 section . IsHeader = true ;
487+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsLibrarySectionExpanded ;
464488
465489 break ;
466490 }
@@ -474,6 +498,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
474498 section = BuildSection ( "Drives" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
475499 iconIdex = Constants . ImageRes . ThisPC ;
476500 section . IsHeader = true ;
501+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsDriveSectionExpanded ;
477502
478503 break ;
479504 }
@@ -487,6 +512,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
487512 section = BuildSection ( "SidebarCloudDrives" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
488513 icon = new BitmapImage ( new Uri ( Constants . FluentIconsPaths . CloudDriveIcon ) ) ;
489514 section . IsHeader = true ;
515+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsCloudDriveSectionExpanded ;
490516
491517 break ;
492518 }
@@ -500,6 +526,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
500526 section = BuildSection ( "Network" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
501527 iconIdex = Constants . ImageRes . Network ;
502528 section . IsHeader = true ;
529+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsNetworkSectionExpanded ;
503530
504531 break ;
505532 }
@@ -513,6 +540,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
513540 section = BuildSection ( "WSL" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
514541 icon = new BitmapImage ( new Uri ( Constants . WslIconsPaths . GenericIcon ) ) ;
515542 section . IsHeader = true ;
543+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsWslSectionExpanded ;
516544
517545 break ;
518546 }
@@ -526,6 +554,7 @@ private async Task<LocationItem> CreateSectionAsync(SectionType sectionType)
526554 section = BuildSection ( "FileTags" . GetLocalizedResource ( ) , sectionType , new ContextMenuOptions { ShowHideSection = true } , false ) ;
527555 icon = new BitmapImage ( new Uri ( Constants . FluentIconsPaths . FileTagsIcon ) ) ;
528556 section . IsHeader = true ;
557+ section . IsExpanded = UserSettingsService . GeneralSettingsService . IsFileTagsSectionExpanded ;
529558
530559 break ;
531560 }
0 commit comments