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 issue where the tab sometimes had the wrong icon #12190

Merged
9 changes: 0 additions & 9 deletions src/Files.App/Filesystem/Cloud/CloudDrivesManager.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.WinUI;
using Files.App.DataModels.NavigationControlItems;
using Files.App.Extensions;
using Files.App.Helpers;
using Files.Shared;
using Files.Shared.Cloud;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using Windows.Storage;

namespace Files.App.Filesystem.Cloud
Expand Down
8 changes: 2 additions & 6 deletions src/Files.App/Filesystem/WSLDistroManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
// Licensed under the MIT License. See the LICENSE.

using Files.App.DataModels.NavigationControlItems;
using Files.App.Helpers;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Threading.Tasks;
using System.Diagnostics.CodeAnalysis;
using Windows.Storage;
using static Files.App.Constants;

Expand Down Expand Up @@ -63,7 +59,7 @@ public async Task UpdateDrivesAsync()
}
}

public bool TryGetDistro(string path, out WslDistroItem? distro)
public bool TryGetDistro(string path, [NotNullWhen(true)] out WslDistroItem? distro)
{
var normalizedPath = PathNormalization.NormalizePath(path);
distro = Distros.FirstOrDefault(x => normalizedPath.StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));
Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,18 @@ public async Task UpdateTabInfo(TabItem tabItem, object navigationArg)
// If localized string is empty use the library name.
tabLocationHeader = string.IsNullOrEmpty(libName) ? library.Text : libName;
}
else if (App.WSLDistroManager.TryGetDistro(currentPath, out WslDistroItem? wslDistro) && currentPath.Equals(wslDistro.Path))
{
tabLocationHeader = wslDistro.Text;
iconSource.ImageSource = new Microsoft.UI.Xaml.Media.Imaging.BitmapImage(wslDistro.Logo);
marcofranzen99 marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
var normalizedCurrentPath = PathNormalization.NormalizePath(currentPath);
var matchingCloudDrive = App.CloudDrivesManager.Drives.FirstOrDefault(x => normalizedCurrentPath.Equals(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));
if (matchingCloudDrive is not null)
{
iconSource.ImageSource = matchingCloudDrive.Icon;
tabLocationHeader = matchingCloudDrive.Text;
}
else if (PathNormalization.NormalizePath(PathNormalization.GetPathRoot(currentPath)) == normalizedCurrentPath) // If path is a drive's root
Expand Down