Skip to content
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

Fix confirm exit dialog potentially showing incorrect number of ongoing operations #28808

Merged
merged 4 commits into from
Jul 12, 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
11 changes: 9 additions & 2 deletions osu.Game.Tests/Visual/Navigation/TestSceneScreenNavigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,18 +838,25 @@ public void TestOverlayClosing()
[Test]
public void TestExitWithOperationInProgress()
{
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
int x = 0;

AddUntilStep("wait for dialog overlay", () =>
{
x = 0;
return Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null;
});

AddRepeatStep("start ongoing operation", () =>
{
Game.Notifications.Post(new ProgressNotification
{
Text = "Something is still running",
Text = $"Something is still running #{++x}",
Progress = 0.5f,
State = ProgressNotificationState.Active,
});
}, 15);

AddAssert("all notifications = 15", () => Game.Notifications.AllNotifications.Count(), () => Is.EqualTo(15));
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
AddUntilStep("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
AddStep("Release escape", () => InputManager.ReleaseKey(Key.Escape));
Expand Down
15 changes: 3 additions & 12 deletions osu.Game/Overlays/NotificationOverlayToastTray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class NotificationOverlayToastTray : CompositeDrawable
/// <summary>
/// All notifications currently being displayed by the toast tray.
/// </summary>
public IEnumerable<Notification> Notifications => toastFlow;
public IEnumerable<Notification> Notifications => toastFlow.Concat(InternalChildren.OfType<Notification>());

public bool IsDisplayingToasts => toastFlow.Count > 0;

Expand All @@ -43,12 +43,7 @@ public partial class NotificationOverlayToastTray : CompositeDrawable

public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }

public int UnreadCount => allDisplayedNotifications.Count(n => !n.WasClosed && !n.Read);

/// <summary>
/// Notifications contained in the toast flow, or in a detached state while they animate during forwarding to the main overlay.
/// </summary>
private IEnumerable<Notification> allDisplayedNotifications => toastFlow.Concat(InternalChildren.OfType<Notification>());
public int UnreadCount => Notifications.Count(n => !n.WasClosed && !n.Read);

private int runningDepth;

Expand Down Expand Up @@ -91,11 +86,7 @@ private void load()
};
}

public void MarkAllRead()
{
toastFlow.Children.ForEach(n => n.Read = true);
InternalChildren.OfType<Notification>().ForEach(n => n.Read = true);
}
public void MarkAllRead() => Notifications.ForEach(n => n.Read = true);

public void FlushAllToasts()
{
Expand Down
Loading