Skip to content

Commit db6ef1c

Browse files
authored
Fix crash when closing combined properties (#8016)
1 parent 700c4cd commit db6ef1c

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

src/Files/Views/Pages/PropertiesGeneral.xaml.cs

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public PropertiesGeneral()
1616
{
1717
this.InitializeComponent();
1818
}
19+
1920
public override async Task<bool> SaveChangesAsync(ListedItem item)
2021
{
2122
if (BaseProperties is DriveProperties driveProps)
@@ -54,7 +55,7 @@ public override async Task<bool> SaveChangesAsync(ListedItem item)
5455
if (AppInstance.FilesystemViewModel != null && App.LibraryManager.CanCreateLibrary(newName).result)
5556
{
5657
var libraryPath = library.ItemPath;
57-
var renamed = await AppInstance.FilesystemHelpers.RenameAsync(new StorageFileWithPath(null, libraryPath), newName, Windows.Storage.NameCollisionOption.FailIfExists, false);
58+
var renamed = await AppInstance.FilesystemHelpers.RenameAsync(new StorageFileWithPath(null, libraryPath), $"{newName}{ShellLibraryItem.EXTENSION}", Windows.Storage.NameCollisionOption.FailIfExists, false);
5859
if (renamed == Enums.ReturnResult.Success)
5960
{
6061
var newPath = Path.Combine(Path.GetDirectoryName(libraryPath), $"{newName}{ShellLibraryItem.EXTENSION}");
@@ -67,38 +68,34 @@ public override async Task<bool> SaveChangesAsync(ListedItem item)
6768
}
6869
}
6970
}
71+
else if (BaseProperties is CombinedProperties combinedProps)
72+
{
73+
// Handle the visibility attribute for multiple files
74+
if (AppInstance?.SlimContentPage?.ItemManipulationModel != null) // null on homepage
75+
{
76+
foreach (var fileOrFolder in combinedProps.List)
77+
{
78+
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIFilesystemHelpers.SetHiddenAttributeItem(fileOrFolder, ViewModel.IsHidden, AppInstance.SlimContentPage.ItemManipulationModel));
79+
}
80+
}
81+
return true;
82+
}
7083
else
7184
{
85+
// Handle the visibility attribute for a single file
86+
if (AppInstance?.SlimContentPage?.ItemManipulationModel != null) // null on homepage
87+
{
88+
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIFilesystemHelpers.SetHiddenAttributeItem(item, ViewModel.IsHidden, AppInstance.SlimContentPage.ItemManipulationModel));
89+
}
90+
7291
ViewModel.ItemName = ItemFileName.Text; // Make sure ItemName is updated
7392
if (!string.IsNullOrWhiteSpace(ViewModel.ItemName) && ViewModel.OriginalItemName != ViewModel.ItemName)
7493
{
7594
return await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIFilesystemHelpers.RenameFileItemAsync(item,
7695
ViewModel.ItemName,
7796
AppInstance));
7897
}
79-
80-
// Handle the hidden attribute
81-
if (BaseProperties is CombinedProperties combinedProps)
82-
{
83-
// Handle each file independently
84-
if (AppInstance?.SlimContentPage?.ItemManipulationModel != null) // null on homepage
85-
{
86-
foreach (var fileOrFolder in combinedProps.List)
87-
{
88-
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIFilesystemHelpers.SetHiddenAttributeItem(fileOrFolder, ViewModel.IsHidden, AppInstance.SlimContentPage.ItemManipulationModel));
89-
}
90-
}
91-
return true;
92-
}
93-
else
94-
{
95-
// Handle the visibility attribute for a single file
96-
if (AppInstance?.SlimContentPage?.ItemManipulationModel != null) // null on homepage
97-
{
98-
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIFilesystemHelpers.SetHiddenAttributeItem(item, ViewModel.IsHidden, AppInstance.SlimContentPage.ItemManipulationModel));
99-
}
100-
return true;
101-
}
98+
return true;
10299
}
103100

104101
return false;

0 commit comments

Comments
 (0)