Skip to content

Commit 142d504

Browse files
authored
Fix: Save tab list on path change (#14874)
1 parent 569dca4 commit 142d504

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/Files.App/Data/Contexts/Multitasking/MultitaskingContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,21 @@ private void AppModel_PropertyChanged(object? sender, PropertyChangedEventArgs e
4545
if (e.PropertyName is nameof(AppModel.TabStripSelectedIndex))
4646
UpdateCurrentTabIndex();
4747
}
48+
4849
private void BaseMultitaskingControl_OnLoaded(object? sender, ITabBar control)
4950
{
5051
SetProperty(ref this.control, control, nameof(Control));
5152
UpdateTabCount();
5253
UpdateCurrentTabIndex();
5354
}
55+
5456
private void HorizontalMultitaskingControl_SelectedTabItemChanged(object? sender, TabBarItem? e)
5557
{
5658
isPopupOpen = e is not null;
5759
int newSelectedIndex = e is null ? currentTabIndex : MainPageViewModel.AppInstances.IndexOf(e);
5860
UpdateSelectedTabIndex(newSelectedIndex);
5961
}
62+
6063
private void FocusManager_GotFocus(object? sender, FocusManagerGotFocusEventArgs e)
6164
{
6265
if (isPopupOpen)
@@ -68,6 +71,7 @@ private void FocusManager_GotFocus(object? sender, FocusManagerGotFocusEventArgs
6871
UpdateSelectedTabIndex(newSelectedIndex);
6972
}
7073
}
74+
7175
private void FocusManager_LosingFocus(object? sender, LosingFocusEventArgs e)
7276
{
7377
if (isPopupOpen)
@@ -83,13 +87,15 @@ private void UpdateTabCount()
8387
{
8488
SetProperty(ref tabCount, (ushort)MainPageViewModel.AppInstances.Count, nameof(TabCount));
8589
}
90+
8691
private void UpdateCurrentTabIndex()
8792
{
8893
if (SetProperty(ref currentTabIndex, (ushort)App.AppModel.TabStripSelectedIndex, nameof(CurrentTabIndex)))
8994
{
9095
OnPropertyChanged(nameof(CurrentTabItem));
9196
}
9297
}
98+
9399
private void UpdateSelectedTabIndex(int index)
94100
{
95101
if (SetProperty(ref selectedTabIndex, (ushort)index, nameof(SelectedTabIndex)))

src/Files.App/Helpers/Navigation/NavigationHelpers.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public static async Task AddNewTabByPathAsync(Type type, string? path, int atInd
6161
MainPageViewModel.AppInstances.Insert(index, tabItem);
6262

6363
App.AppModel.TabStripSelectedIndex = index;
64-
65-
// Save the updated tab list
66-
AppLifecycleHelper.SaveSessionTabs();
6764
}
6865

6966
public static async Task AddNewTabByParamAsync(Type type, object tabViewItemArgs, int atIndex = -1)
@@ -89,9 +86,6 @@ public static async Task AddNewTabByParamAsync(Type type, object tabViewItemArgs
8986
var index = atIndex == -1 ? MainPageViewModel.AppInstances.Count : atIndex;
9087
MainPageViewModel.AppInstances.Insert(index, tabItem);
9188
App.AppModel.TabStripSelectedIndex = index;
92-
93-
// Save the updated tab list
94-
AppLifecycleHelper.SaveSessionTabs();
9589
}
9690

9791
private static async Task UpdateTabInfoAsync(TabBarItem tabItem, object navigationArg)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public async void TabItemContent_ContentChanged(object? sender, CustomTabViewIte
167167
LoadPaneChanged();
168168
UpdateNavToolbarProperties();
169169
await NavigationHelpers.UpdateInstancePropertiesAsync(paneArgs);
170+
171+
// Save the updated tab list
172+
AppLifecycleHelper.SaveSessionTabs();
170173
}
171174

172175
public async void MultitaskingControl_CurrentInstanceChanged(object? sender, CurrentInstanceChangedEventArgs e)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ public bool IsRightPaneVisible
166166
{
167167
_IsRightPaneVisible = value;
168168
if (!_IsRightPaneVisible)
169+
{
169170
ActivePane = PaneLeft;
171+
Pane_ContentChanged(null, null);
172+
}
170173

171-
Pane_ContentChanged(null, null);
172174
NotifyPropertyChanged(nameof(IsRightPaneVisible));
173175
NotifyPropertyChanged(nameof(IsMultiPaneActive));
174176
}

0 commit comments

Comments
 (0)