mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 04:02:54 +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.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
@ -13,7 +11,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
public class TestSceneStartupImport : OsuGameTestScene
|
||||
{
|
||||
private string importFilename;
|
||||
private string? 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.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
base.LoadComplete();
|
||||
|
||||
// we may have received changes before we were displayed.
|
||||
updateState();
|
||||
Scheduler.AddOnce(updateState);
|
||||
}
|
||||
|
||||
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
|
||||
@ -87,13 +87,8 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
state = value;
|
||||
|
||||
if (IsLoaded)
|
||||
{
|
||||
Schedule(updateState);
|
||||
|
||||
if (state == ProgressNotificationState.Completed)
|
||||
CompletionTarget?.Invoke(CreateCompletionNotification());
|
||||
}
|
||||
Scheduler.AddOnce(updateState);
|
||||
attemptPostCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +141,33 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
case ProgressNotificationState.Completed:
|
||||
loadingSpinner.Hide();
|
||||
attemptPostCompletion();
|
||||
base.Close();
|
||||
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;
|
||||
|
||||
protected virtual Notification CreateCompletionNotification() => new ProgressCompletionNotification
|
||||
|
Loading…
Reference in New Issue
Block a user