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 path bar didn't use localized name for system folders #14532

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ public static List<PathBoxItem> GetDirectoryPathComponents(string value)
return pathBoxItems;
}

public static async Task<List<PathBoxItem>> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/BaseLayoutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/Shells/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Shells/IShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Views/Shells/ModernShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down