Skip to content

Fix: Fixed issue where the path bar on the home page was not translated #14694

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

Merged
merged 4 commits into from
Feb 11, 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
13 changes: 9 additions & 4 deletions src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,15 @@ public static async Task<List<PathBoxItem>> GetDirectoryPathComponentsWithDispla

foreach (var item in pathBoxItems)
{
BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path));
if (item.Path == "Home")
item.Title = "Home".GetLocalizedResource();
else
{
BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path));

if (folder is not null)
item.Title = folder.DisplayName;
if (folder is not null)
item.Title = folder.DisplayName;
}
}

return pathBoxItems;
Expand Down Expand Up @@ -417,4 +422,4 @@ private static void SetCurrentWorkingDirectory(StringBuilder path, char separato
i = -1;
}
}
}
}
24 changes: 12 additions & 12 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ protected async void DrivesManager_PropertyChanged(object sender, PropertyChange
await DisplayFilesystemConsentDialogAsync();
}

private TaskCompletionSource? _getDisplayNameTCS;
private volatile CancellationTokenSource? cts;

// Ensure that the path bar gets updated for user interaction
// whenever the path changes.We will get the individual directories from
Expand All @@ -468,25 +468,25 @@ public async Task UpdatePathUIToWorkingDirectoryAsync(string newWorkingDir, stri
{
if (string.IsNullOrWhiteSpace(singleItemOverride))
{
// We need override the path bar when searching, so we use TaskCompletionSource
// to ensure that the override occurs after GetDirectoryPathComponentsWithDisplayNameAsync.
var tcs = new TaskCompletionSource();
_getDisplayNameTCS = tcs;
cts = new CancellationTokenSource();

var components = await StorageFileExtensions.GetDirectoryPathComponentsWithDisplayNameAsync(newWorkingDir);

// Cancel if overrided by single item
if (cts.IsCancellationRequested)
{
cts = null;
return;
}
cts = null;

ToolbarViewModel.PathComponents.Clear();
foreach (var component in components)
ToolbarViewModel.PathComponents.Add(component);

tcs.TrySetResult();
_getDisplayNameTCS = null;
}
else
{
// Wait if awaiting GetDirectoryPathComponentsWithDisplayNameAsync
var tcs = _getDisplayNameTCS;
if (tcs is not null)
await tcs.Task;
cts?.Cancel();

// Clear the path UI
ToolbarViewModel.PathComponents.Clear();
Expand Down