Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private async void Window_Closed(object sender, WindowEventArgs args)
!Process.GetProcessesByName("Files").Any(x => x.Id != Environment.ProcessId))
{
// Close open content dialogs
UIHelpers.CloseAllDialogs();
await UIHelpers.CloseAllDialogsAsync();

// Close all notification banners except in progress
statusCenterViewModel.RemoveAllCompletedItems();
Expand Down
20 changes: 20 additions & 0 deletions src/Files.App/Helpers/UI/UIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ public static void CloseAllDialogs()
dialog.Hide();
}

public static async Task CloseAllDialogsAsync()
{
if (MainWindow.Instance?.Content?.XamlRoot == null)
return;

var openedDialogs = VisualTreeHelper.GetOpenPopupsForXamlRoot(MainWindow.Instance.Content.XamlRoot);
var closingTasks = new List<Task>();
foreach (var item in openedDialogs)
{
if (item.Child is ContentDialog dialog)
{
var tcs = new TaskCompletionSource();
dialog.Closed += (s, e) => tcs.SetResult();
dialog.Hide();
closingTasks.Add(tcs.Task);
}
}
await Task.WhenAll(closingTasks);
}

private static IEnumerable<IconFileInfo> SidebarIconResources = LoadSidebarIconResources();

private static IconFileInfo ShieldIconResource = LoadShieldIconResource();
Expand Down
Loading