Skip to content

Commit 5895358

Browse files
ferrariofilippoyaira2
authored andcommitted
Fix: Keep sort and group options consistent between tabs
1 parent 40af234 commit 5895358

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

src/Files.App/Data/Contracts/IShellPanesPage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,10 @@ public interface IShellPanesPage : IDisposable, INotifyPropertyChanged
5858
/// Focuses the other pane.
5959
/// </summary>
6060
public void FocusOtherPane();
61+
62+
/// <summary>
63+
/// Updates the layout of open panes.
64+
/// </summary>
65+
public void UpdatePanesLayout();
6166
}
6267
}

src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ public Type GetLayoutType(string path, bool changeLayoutMode = true)
265265
};
266266
}
267267

268+
public void UpdateGroupAndSortOptions(string? path)
269+
{
270+
if (string.IsNullOrWhiteSpace(path))
271+
return;
272+
273+
var preferencesItem = GetLayoutPreferencesForPath(path);
274+
if (preferencesItem is null)
275+
return;
276+
277+
DirectorySortOption = preferencesItem.DirectorySortOption;
278+
DirectorySortDirection = preferencesItem.DirectorySortDirection;
279+
DirectoryGroupOption = preferencesItem.DirectoryGroupOption;
280+
DirectoryGroupByDateUnit = preferencesItem.DirectoryGroupByDateUnit;
281+
DirectoryGroupDirection = preferencesItem.DirectoryGroupDirection;
282+
}
283+
268284
public bool IsPathUsingDefaultLayout(string? path)
269285
{
270286
return UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories ||

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ public async void MultitaskingControl_CurrentInstanceChanged(object? sender, Cur
171171
{
172172
SidebarAdaptiveViewModel.PaneHolder = currentInstance;
173173
SidebarAdaptiveViewModel.PaneHolder.PropertyChanged += PaneHolder_PropertyChanged;
174+
// Issue doesn't update the secondary pane in general
175+
currentInstance.UpdatePanesLayout();
174176
}
175177
SidebarAdaptiveViewModel.NotifyInstanceRelatedPropertiesChanged((navArgs as PaneNavigationArguments)?.LeftPaneNavPathParam);
176178

src/Files.App/Views/ShellPanesPage.xaml.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ public IShellPage? ActivePane
185185
secondShellPage.IsCurrentInstance = false;
186186

187187
if (ActivePane is not null)
188+
{
188189
ActivePane.IsCurrentInstance = IsCurrentInstance;
190+
UpdatePaneLayout(ActivePane);
191+
}
189192

190193
NotifyPropertyChanged(nameof(ActivePane));
191194
NotifyPropertyChanged(nameof(IsLeftPaneActive));
@@ -356,6 +359,17 @@ public void FocusOtherPane()
356359
GetPane(0)?.Focus(FocusState.Programmatic);
357360
}
358361

362+
/// <inheritdoc/>
363+
public void UpdatePanesLayout()
364+
{
365+
if (GetPane(0) is IShellPage leftPane)
366+
UpdatePaneLayout(leftPane);
367+
368+
369+
if (GetPane(1) is IShellPage rightPane)
370+
UpdatePaneLayout(rightPane);
371+
}
372+
359373
// Private methods
360374

361375
private ModernShellPage? GetPane(int index = -1)
@@ -603,6 +617,13 @@ paneArgs.ShellPaneArrangement is ShellPaneArrangement.None
603617
};
604618
}
605619

620+
private void UpdatePaneLayout(IShellPage pane)
621+
{
622+
var page = pane.SlimContentPage as BaseLayoutPage;
623+
var path = pane.ShellViewModel.CurrentFolder?.ItemPath;
624+
page?.FolderSettings?.UpdateGroupAndSortOptions(path);
625+
}
626+
606627
// Event methods
607628

608629
public Task TabItemDragOver(object sender, DragEventArgs e)

0 commit comments

Comments
 (0)