mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 07:42:58 +08:00
Fix completion notification not being posted if completion occurs during NotificationOverlay
load
This commit is contained in:
parent
510972e3ad
commit
9e3228aa65
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
@ -13,7 +11,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
public class TestSceneStartupImport : OsuGameTestScene
|
public class TestSceneStartupImport : OsuGameTestScene
|
||||||
{
|
{
|
||||||
private string importFilename;
|
private string? importFilename;
|
||||||
|
|
||||||
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });
|
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
// we may have received changes before we were displayed.
|
// we may have received changes before we were displayed.
|
||||||
updateState();
|
Scheduler.AddOnce(updateState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||||
@ -87,13 +87,8 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
state = value;
|
state = value;
|
||||||
|
|
||||||
if (IsLoaded)
|
Scheduler.AddOnce(updateState);
|
||||||
{
|
attemptPostCompletion();
|
||||||
Schedule(updateState);
|
|
||||||
|
|
||||||
if (state == ProgressNotificationState.Completed)
|
|
||||||
CompletionTarget?.Invoke(CreateCompletionNotification());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,11 +141,33 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
case ProgressNotificationState.Completed:
|
case ProgressNotificationState.Completed:
|
||||||
loadingSpinner.Hide();
|
loadingSpinner.Hide();
|
||||||
|
attemptPostCompletion();
|
||||||
base.Close();
|
base.Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool completionSent;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempt to post a completion notification.
|
||||||
|
/// </summary>
|
||||||
|
private void attemptPostCompletion()
|
||||||
|
{
|
||||||
|
if (state != ProgressNotificationState.Completed) return;
|
||||||
|
|
||||||
|
// This notification may not have been posted yet (and thus may not have a target to post the completion to).
|
||||||
|
// Completion posting will be re-attempted in a scheduled invocation.
|
||||||
|
if (CompletionTarget == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (completionSent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CompletionTarget.Invoke(CreateCompletionNotification());
|
||||||
|
completionSent = true;
|
||||||
|
}
|
||||||
|
|
||||||
private ProgressNotificationState state;
|
private ProgressNotificationState state;
|
||||||
|
|
||||||
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
|
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
|
||||||
|
Loading…
Reference in New Issue
Block a user