Skip to content

Commit

Permalink
Fix: Fixed issue where folders sizes weren't calculated when opening …
Browse files Browse the repository at this point in the history
…Properties from the sidebar (files-community#14480)
  • Loading branch information
ferrariofilippo authored Jan 16, 2024
1 parent 16bb923 commit 6649e82
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
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

0 comments on commit 6649e82

Please sign in to comment.