forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Fixed issue where changing a folder's grouping preference wouldn…
…'t update other open tabs (files-community#16572)
- Loading branch information
1 parent
02c2320
commit f20e3a9
Showing
9 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Files Community | ||
// Licensed under the MIT License. | ||
|
||
namespace Files.App.Helpers | ||
{ | ||
static class LayoutHelpers | ||
{ | ||
public static void UpdateOpenTabsPreferences() | ||
{ | ||
// Services | ||
var multitaskingContext = Ioc.Default.GetRequiredService<IMultitaskingContext>(); | ||
var layoutSettingsService = Ioc.Default.GetRequiredService<ILayoutSettingsService>(); | ||
|
||
// Get all tab instances and active path | ||
var tabs = multitaskingContext.Control?.GetAllTabInstances(); | ||
var activePath = (multitaskingContext.CurrentTabItem?.TabItemContent as ShellPanesPage)?.ActivePane?.TabBarItemParameter?.NavigationParameter as string; | ||
|
||
// Return if required data is missing | ||
if (tabs is null || activePath is null) | ||
return; | ||
|
||
for (int i = 0; i < tabs.Count; i++) | ||
{ | ||
var isNotCurrentTab = i != multitaskingContext.CurrentTabIndex; | ||
var shPage = tabs[i] as ShellPanesPage; | ||
|
||
if (shPage is not null) | ||
{ | ||
foreach (var pane in shPage.GetPanes()) | ||
{ | ||
var path = pane.ShellViewModel?.CurrentFolder?.ItemPath; | ||
|
||
// Skip panes without a valid path | ||
if (path is null) | ||
continue; | ||
|
||
// Check if we need to update preferences for this pane | ||
if ((isNotCurrentTab || pane != shPage.ActivePane) && | ||
(layoutSettingsService.SyncFolderPreferencesAcrossDirectories || | ||
path.Equals(activePath, StringComparison.OrdinalIgnoreCase))) | ||
if (pane.SlimContentPage is BaseLayoutPage page) | ||
page.FolderSettings?.ReloadGroupAndSortPreferences(path); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters