Skip to content

Fix: Fixed issue where folders sizes weren't calculated when opening Properties from the sidebar #14480

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
Jan 16, 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: 12 additions & 3 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,8 +1642,17 @@ await Task.Run(async () =>
});

rootFolder ??= await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path));
if (rootFolder?.DisplayName is not null)
currentFolder.ItemNameRaw = rootFolder.DisplayName;
if (rootFolder is not null)
{
if (rootFolder.DisplayName is not null)
currentFolder.ItemNameRaw = rootFolder.DisplayName;

if (!string.Equals(path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
{
var syncStatus = await CheckCloudDriveSyncStatusAsync(rootFolder);
currentFolder.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
}
}

return 0;
}
Expand Down Expand Up @@ -1691,7 +1700,7 @@ private void CheckForSolutionFile()
.FirstOrDefault()?.ItemPath;
}

private async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
public async Task<CloudDriveSyncStatus> CheckCloudDriveSyncStatusAsync(IStorageItem item)
{
int? syncStatus = null;
if (item is BaseStorageFile file && file.Properties is not null)
Expand Down
14 changes: 12 additions & 2 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ private async Task ReorderItemsAsync()
private void OpenProperties(CommandBarFlyout menu)
{
EventHandler<object> flyoutClosed = null!;
flyoutClosed = (s, e) =>
flyoutClosed = async (s, e) =>
{
menu.Closed -= flyoutClosed;
if (rightClickedItem is DriveItem)
Expand All @@ -900,14 +900,24 @@ private void OpenProperties(CommandBarFlyout menu)
FilePropertiesHelpers.OpenPropertiesWindow(new LibraryItem(library), PaneHolder.ActivePane);
else if (rightClickedItem is LocationItem locationItem)
{
ListedItem listedItem = new ListedItem(null!)
var listedItem = new ListedItem(null!)
{
ItemPath = locationItem.Path,
ItemNameRaw = locationItem.Text,
PrimaryItemAttribute = StorageItemTypes.Folder,
ItemType = "Folder".GetLocalizedResource(),
};

if (!string.Equals(locationItem.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
{
BaseStorageFolder matchingStorageFolder = await PaneHolder.ActivePane.FilesystemViewModel.GetFolderFromPathAsync(locationItem.Path);
if (matchingStorageFolder is not null)
{
var syncStatus = await PaneHolder.ActivePane.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder);
listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
}
}

FilePropertiesHelpers.OpenPropertiesWindow(listedItem, PaneHolder.ActivePane);
}
};
Expand Down
12 changes: 11 additions & 1 deletion src/Files.App/Views/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private void WidgetCardNewPaneInvoked(object sender, QuickAccessCardInvokedEvent
AppInstance.PaneHolder?.OpenPathInNewPane(e.Path);
}

private void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessCardEventArgs e)
private async void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessCardEventArgs e)
{
ListedItem listedItem = new(null!)
{
Expand All @@ -255,6 +255,16 @@ private void QuickAccessWidget_CardPropertiesInvoked(object sender, QuickAccessC
ItemType = "Folder".GetLocalizedResource(),
};

if (!string.Equals(e.Item.Path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
{
BaseStorageFolder matchingStorageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(e.Item.Path);
if (matchingStorageFolder is not null)
{
var syncStatus = await AppInstance.FilesystemViewModel.CheckCloudDriveSyncStatusAsync(matchingStorageFolder);
listedItem.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
}
}

FilePropertiesHelpers.OpenPropertiesWindow(listedItem, AppInstance);
}

Expand Down