Skip to content

Commit

Permalink
Fix: Fixed NullReferenceException in MainPageViewModel.UpdateInstance…
Browse files Browse the repository at this point in the history
…PropertiesAsync (#13900)
  • Loading branch information
hishitetsu authored Nov 16, 2023
1 parent 4826f55 commit f7fa6fa
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/Files.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,33 @@ public async Task AddNewTabByPathAsync(Type type, string? path, int atIndex = -1

public async Task UpdateInstancePropertiesAsync(object navigationArg)
{
string windowTitle = string.Empty;
if (navigationArg is PaneNavigationArguments paneArgs)
await SafetyExtensions.IgnoreExceptions(async () =>
{
if (!string.IsNullOrEmpty(paneArgs.LeftPaneNavPathParam) && !string.IsNullOrEmpty(paneArgs.RightPaneNavPathParam))
string windowTitle = string.Empty;
if (navigationArg is PaneNavigationArguments paneArgs)
{
var leftTabInfo = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
var rightTabInfo = await GetSelectedTabInfoAsync(paneArgs.RightPaneNavPathParam);
windowTitle = $"{leftTabInfo.tabLocationHeader} | {rightTabInfo.tabLocationHeader}";
if (!string.IsNullOrEmpty(paneArgs.LeftPaneNavPathParam) && !string.IsNullOrEmpty(paneArgs.RightPaneNavPathParam))
{
var leftTabInfo = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
var rightTabInfo = await GetSelectedTabInfoAsync(paneArgs.RightPaneNavPathParam);
windowTitle = $"{leftTabInfo.tabLocationHeader} | {rightTabInfo.tabLocationHeader}";
}
else
{
(windowTitle, _, _) = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
}
}
else
else if (navigationArg is string pathArgs)
{
(windowTitle, _, _) = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
(windowTitle, _, _) = await GetSelectedTabInfoAsync(pathArgs);
}
}
else if (navigationArg is string pathArgs)
{
(windowTitle, _, _) = await GetSelectedTabInfoAsync(pathArgs);
}

if (AppInstances.Count > 1)
windowTitle = $"{windowTitle} ({AppInstances.Count})";
if (AppInstances.Count > 1)
windowTitle = $"{windowTitle} ({AppInstances.Count})";

if (navigationArg == SelectedTabItem?.NavigationParameter?.NavigationParameter)
MainWindow.Instance.AppWindow.Title = $"{windowTitle} - Files";
if (navigationArg == SelectedTabItem?.NavigationParameter?.NavigationParameter)
MainWindow.Instance.AppWindow.Title = $"{windowTitle} - Files";
});
}

public async Task UpdateTabInfoAsync(Files.App.UserControls.TabBar.TabBarItem tabItem, object navigationArg)
Expand Down

0 comments on commit f7fa6fa

Please sign in to comment.