Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed NullReferenceException in MainPageViewModel.UpdateInstancePropertiesAsync #13900

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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