Skip to content

Commit

Permalink
Fix: Fixed issue where the path bar on the home page was not translat…
Browse files Browse the repository at this point in the history
…ed (#14694)
  • Loading branch information
hishitetsu authored Feb 11, 2024
1 parent 12db113 commit cb9412a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
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

0 comments on commit cb9412a

Please sign in to comment.