Skip to content

Commit 6649e82

Browse files
Fix: Fixed issue where folders sizes weren't calculated when opening Properties from the sidebar (#14480)
1 parent 16bb923 commit 6649e82

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

src/Files.App/Data/Models/ItemViewModel.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,8 +1642,17 @@ await Task.Run(async () =>
16421642
});
16431643

16441644
rootFolder ??= await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path));
1645-
if (rootFolder?.DisplayName is not null)
1646-
currentFolder.ItemNameRaw = rootFolder.DisplayName;
1645+
if (rootFolder is not null)
1646+
{
1647+
if (rootFolder.DisplayName is not null)
1648+
currentFolder.ItemNameRaw = rootFolder.DisplayName;
1649+
1650+
if (!string.Equals(path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
1651+
{
1652+
var syncStatus = await CheckCloudDriveSyncStatusAsync(rootFolder);
1653+
currentFolder.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
1654+
}
1655+
}
16471656

16481657
return 0;
16491658
}
@@ -1691,7 +1700,7 @@ private void CheckForSolutionFile()
16911700
.FirstOrDefault()?.ItemPath;
16921701
}
16931702

1694-
private async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
1703+
public async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
16951704
{
16961705
int? syncStatus = null;
16971706
if (item is BaseStorageFile file && file.Properties is not null)

src/Files.App/ViewModels/UserControls/SidebarViewModel.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ private async Task ReorderItemsAsync()
891891
private void OpenProperties(CommandBarFlyout menu)
892892
{
893893
EventHandler<object> flyoutClosed = null!;
894-
flyoutClosed = (s, e) =>
894+
flyoutClosed = async (s, e) =>
895895
{
896896
menu.Closed -= flyoutClosed;
897897
if (rightClickedItem is DriveItem)
@@ -900,14 +900,24 @@ private void OpenProperties(CommandBarFlyout menu)
900900
FilePropertiesHelpers.OpenPropertiesWindow(new LibraryItem(library), PaneHolder.ActivePane);
901901
else if (rightClickedItem is LocationItem locationItem)
902902
{
903-
ListedItem listedItem = new ListedItem(null!)
903+
var listedItem = new ListedItem(null!)
904904
{
905905
ItemPath = locationItem.Path,
906906
ItemNameRaw = locationItem.Text,
907907
PrimaryItemAttribute = StorageItemTypes.Folder,
908908
ItemType = "Folder".GetLocalizedResource(),
909909
};
910910

911+
if (!string.Equals(locationItem.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
912+
{
913+
BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.FilesystemViewModel.GetFolderFromPathAsync(locationItem.Path);
914+
if (matchingStorageFolder is not null)
915+
{
916+
var syncStatus = await PaneHolder.ActivePane.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder);
917+
listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
918+
}
919+
}
920+
911921
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, PaneHolder.ActivePane);
912922
}
913923
};

src/Files.App/Views/HomePage.xaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ private void WidgetCardNewPaneInvoked(object sender, QuickAccessCardInvokedEvent
245245
AppInstance.PaneHolder?.OpenPathInNewPane(e.Path);
246246
}
247247

248-
private void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessCardEventArgs e)
248+
private async void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessCardEventArgs e)
249249
{
250250
ListedItem listedItem = new(null!)
251251
{
@@ -255,6 +255,16 @@ private void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessC
255255
ItemType = "Folder".GetLocalizedResource(),
256256
};
257257

258+
if (!string.Equals(e.Item.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
259+
{
260+
BaseStorageFolder matchingStorageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(e.Item.Path);
261+
if (matchingStorageFolder is not null)
262+
{
263+
var syncStatus = await AppInstance.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder);
264+
listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
265+
}
266+
}
267+
258268
FilePropertiesHelpers.OpenPropertiesWindow(listedItem, AppInstance);
259269
}
260270

0 commit comments

Comments
 (0)