Skip to content

Commit 6ade754

Browse files
authored
Fixed repeatedly clicking Restore Default button causing crash (#7891)
1 parent 7d21904 commit 6ade754

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Files/Views/CustomFolderIcons.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Windows.ApplicationModel.AppService;
1111
using Windows.ApplicationModel.Core;
1212
using Windows.Foundation.Collections;
13+
using Windows.UI.Core;
1314
using Windows.UI.Xaml;
1415
using Windows.UI.Xaml.Controls;
1516
using Windows.UI.Xaml.Navigation;
@@ -111,14 +112,19 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() =>
111112

112113
private async Task RestoreDefaultIcon()
113114
{
115+
RestoreDefaultButton.IsEnabled = false;
116+
114117
var setIconTask = IsShortcutItem ?
115118
SetCustomFileIcon(selectedItemPath, null) :
116119
SetCustomFolderIcon(selectedItemPath, null);
117120
if (await setIconTask)
118121
{
119122
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() =>
120123
{
121-
appInstance?.FilesystemViewModel?.RefreshItems(null);
124+
appInstance?.FilesystemViewModel?.RefreshItems(null, async () =>
125+
{
126+
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => RestoreDefaultButton.IsEnabled = true);
127+
});
122128
});
123129
}
124130
}

0 commit comments

Comments
 (0)