diff --git a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs index 069839c9ba53..423f86a4566b 100644 --- a/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs +++ b/src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs @@ -132,6 +132,21 @@ public static List GetDirectoryPathComponents(string value) return pathBoxItems; } + public static async Task> GetDirectoryPathComponentsWithDisplayNameAsync(string value) + { + var pathBoxItems = GetDirectoryPathComponents(value); + + foreach (var item in pathBoxItems) + { + BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path)); + + if (folder is not null) + item.Title = folder.DisplayName; + } + + return pathBoxItems; + } + public static string GetResolvedPath(string path, bool isFtp) { var withoutEnvirnment = GetPathWithoutEnvironmentVariable(path); diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index 6e216d8fee76..6db5912c62f3 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -462,7 +462,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e) if (!navigationArguments.IsLayoutSwitch) { var displayName = App.LibraryManager.TryGetLibrary(navigationArguments.SearchPathParam, out var lib) ? lib.Text : navigationArguments.SearchPathParam; - ParentShellPageInstance.UpdatePathUIToWorkingDirectory(null, string.Format("SearchPagePathBoxOverrideText".GetLocalizedResource(), navigationArguments.SearchQuery, displayName)); + await ParentShellPageInstance.UpdatePathUIToWorkingDirectoryAsync(null, string.Format("SearchPagePathBoxOverrideText".GetLocalizedResource(), navigationArguments.SearchQuery, displayName)); var searchInstance = new Utils.Storage.FolderSearch { Query = navigationArguments.SearchQuery, diff --git a/src/Files.App/Views/Shells/BaseShellPage.cs b/src/Files.App/Views/Shells/BaseShellPage.cs index 3387f2625a9e..cc972747d217 100644 --- a/src/Files.App/Views/Shells/BaseShellPage.cs +++ b/src/Files.App/Views/Shells/BaseShellPage.cs @@ -462,11 +462,11 @@ protected async void DrivesManager_PropertyChanged(object sender, PropertyChange // Ensure that the path bar gets updated for user interaction // whenever the path changes.We will get the individual directories from // the updated, most-current path and add them to the UI. - public void UpdatePathUIToWorkingDirectory(string newWorkingDir, string singleItemOverride = null) + public async Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, string singleItemOverride = null) { if (string.IsNullOrWhiteSpace(singleItemOverride)) { - var components = StorageFileExtensions.GetDirectoryPathComponents(newWorkingDir); + var components = await StorageFileExtensions.GetDirectoryPathComponentsWithDisplayNameAsync(newWorkingDir); ToolbarViewModel.PathComponents.Clear(); foreach (var component in components) ToolbarViewModel.PathComponents.Add(component); diff --git a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs index a7fafb629a83..d9939edeae68 100644 --- a/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ColumnShellPage.xaml.cs @@ -91,11 +91,11 @@ protected override void Page_Loaded(object sender, RoutedEventArgs e) NotifyPropertyChanged(nameof(FilesystemViewModel)); } - protected override void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) + protected override async void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) { string value = e.Path; if (!string.IsNullOrWhiteSpace(value)) - UpdatePathUIToWorkingDirectory(value); + await UpdatePathUIToWorkingDirectoryAsync(value); } private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e) diff --git a/src/Files.App/Views/Shells/IShellPage.cs b/src/Files.App/Views/Shells/IShellPage.cs index 21c31e72c4e0..bee310586cc7 100644 --- a/src/Files.App/Views/Shells/IShellPage.cs +++ b/src/Files.App/Views/Shells/IShellPage.cs @@ -46,7 +46,7 @@ public interface IShellPage : ITabBarItemContent, IMultiPaneInfo, IDisposable, I void Up_Click(); - void UpdatePathUIToWorkingDirectory(string newWorkingDir, string singleItemOverride = null); + Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, string singleItemOverride = null); void NavigateToPath(string navigationPath, Type sourcePageType, NavigationArguments navArgs = null); diff --git a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs index 2c77cd2c448e..a1c09c4f50e5 100644 --- a/src/Files.App/Views/Shells/ModernShellPage.xaml.cs +++ b/src/Files.App/Views/Shells/ModernShellPage.xaml.cs @@ -137,15 +137,15 @@ protected override void OnNavigationParamsChanged() } } - protected override void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) + protected override async void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e) { if (string.IsNullOrWhiteSpace(e.Path)) return; if (e.IsLibrary) - UpdatePathUIToWorkingDirectory(null, e.Name); + await UpdatePathUIToWorkingDirectoryAsync(null, e.Name); else - UpdatePathUIToWorkingDirectory(e.Path); + await UpdatePathUIToWorkingDirectoryAsync(e.Path); } private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e)