mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 10:23:03 +08:00
Merge pull request #28808 from frenzibyte/fix-all-notifications
Fix confirm exit dialog potentially showing incorrect number of ongoing operations
This commit is contained in:
commit
452fbed681
@ -838,18 +838,25 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestExitWithOperationInProgress()
|
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", () =>
|
AddRepeatStep("start ongoing operation", () =>
|
||||||
{
|
{
|
||||||
Game.Notifications.Post(new ProgressNotification
|
Game.Notifications.Post(new ProgressNotification
|
||||||
{
|
{
|
||||||
Text = "Something is still running",
|
Text = $"Something is still running #{++x}",
|
||||||
Progress = 0.5f,
|
Progress = 0.5f,
|
||||||
State = ProgressNotificationState.Active,
|
State = ProgressNotificationState.Active,
|
||||||
});
|
});
|
||||||
}, 15);
|
}, 15);
|
||||||
|
|
||||||
|
AddAssert("all notifications = 15", () => Game.Notifications.AllNotifications.Count(), () => Is.EqualTo(15));
|
||||||
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
||||||
AddUntilStep("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
AddUntilStep("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
||||||
AddStep("Release escape", () => InputManager.ReleaseKey(Key.Escape));
|
AddStep("Release escape", () => InputManager.ReleaseKey(Key.Escape));
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Overlays
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// All notifications currently being displayed by the toast tray.
|
/// All notifications currently being displayed by the toast tray.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<Notification> Notifications => toastFlow;
|
public IEnumerable<Notification> Notifications => toastFlow.Concat(InternalChildren.OfType<Notification>());
|
||||||
|
|
||||||
public bool IsDisplayingToasts => toastFlow.Count > 0;
|
public bool IsDisplayingToasts => toastFlow.Count > 0;
|
||||||
|
|
||||||
@ -43,12 +43,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }
|
public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }
|
||||||
|
|
||||||
public int UnreadCount => allDisplayedNotifications.Count(n => !n.WasClosed && !n.Read);
|
public int UnreadCount => Notifications.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>());
|
|
||||||
|
|
||||||
private int runningDepth;
|
private int runningDepth;
|
||||||
|
|
||||||
@ -91,11 +86,7 @@ namespace osu.Game.Overlays
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkAllRead()
|
public void MarkAllRead() => Notifications.ForEach(n => n.Read = true);
|
||||||
{
|
|
||||||
toastFlow.Children.ForEach(n => n.Read = true);
|
|
||||||
InternalChildren.OfType<Notification>().ForEach(n => n.Read = true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void FlushAllToasts()
|
public void FlushAllToasts()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user