Skip to content

Commit cb9412a

Browse files
authored
Fix: Fixed issue where the path bar on the home page was not translated (#14694)
1 parent 12db113 commit cb9412a

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/Files.App/Utils/Storage/Helpers/StorageFileExtensions.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,15 @@ public static async Task<List<PathBoxItem>> GetDirectoryPathComponentsWithDispla
138138

139139
foreach (var item in pathBoxItems)
140140
{
141-
BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path));
141+
if (item.Path == "Home")
142+
item.Title = "Home".GetLocalizedResource();
143+
else
144+
{
145+
BaseStorageFolder folder = await FilesystemTasks.Wrap(() => DangerousGetFolderFromPathAsync(item.Path));
142146

143-
if (folder is not null)
144-
item.Title = folder.DisplayName;
147+
if (folder is not null)
148+
item.Title = folder.DisplayName;
149+
}
145150
}
146151

147152
return pathBoxItems;
@@ -417,4 +422,4 @@ private static void SetCurrentWorkingDirectory(StringBuilder path, char separato
417422
i = -1;
418423
}
419424
}
420-
}
425+
}

src/Files.App/Views/Shells/BaseShellPage.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ protected async void DrivesManager_PropertyChanged(object sender, PropertyChange
459459
await DisplayFilesystemConsentDialogAsync();
460460
}
461461

462-
private TaskCompletionSource? _getDisplayNameTCS;
462+
private volatile CancellationTokenSource? cts;
463463

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

476473
var components = await StorageFileExtensions.GetDirectoryPathComponentsWithDisplayNameAsync(newWorkingDir);
474+
475+
// Cancel if overrided by single item
476+
if (cts.IsCancellationRequested)
477+
{
478+
cts = null;
479+
return;
480+
}
481+
cts = null;
482+
477483
ToolbarViewModel.PathComponents.Clear();
478484
foreach (var component in components)
479485
ToolbarViewModel.PathComponents.Add(component);
480-
481-
tcs.TrySetResult();
482-
_getDisplayNameTCS = null;
483486
}
484487
else
485488
{
486-
// Wait if awaiting GetDirectoryPathComponentsWithDisplayNameAsync
487-
var tcs = _getDisplayNameTCS;
488-
if (tcs is not null)
489-
await tcs.Task;
489+
cts?.Cancel();
490490

491491
// Clear the path UI
492492
ToolbarViewModel.PathComponents.Clear();

0 commit comments

Comments
 (0)