mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 02:43:16 +08:00
Display the "restart to update" notification on checking for update after dismissal
This commit is contained in:
parent
22b0105d62
commit
de47392e3d
@ -29,6 +29,11 @@ namespace osu.Desktop.Updater
|
|||||||
|
|
||||||
private static readonly Logger logger = Logger.GetLogger("updater");
|
private static readonly Logger logger = Logger.GetLogger("updater");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether an update has been downloaded but not yet applied.
|
||||||
|
/// </summary>
|
||||||
|
private bool updatePending;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(NotificationOverlay notification)
|
private void load(NotificationOverlay notification)
|
||||||
{
|
{
|
||||||
@ -49,9 +54,19 @@ namespace osu.Desktop.Updater
|
|||||||
updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
|
updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true);
|
||||||
|
|
||||||
var info = await updateManager.CheckForUpdate(!useDeltaPatching);
|
var info = await updateManager.CheckForUpdate(!useDeltaPatching);
|
||||||
|
|
||||||
if (info.ReleasesToApply.Count == 0)
|
if (info.ReleasesToApply.Count == 0)
|
||||||
|
{
|
||||||
|
if (updatePending)
|
||||||
|
{
|
||||||
|
// the user may have dismissed the completion notice, so show it again.
|
||||||
|
notificationOverlay.Post(new UpdateCompleteNotification(this));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// no updates available. bail and retry later.
|
// no updates available. bail and retry later.
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (notification == null)
|
if (notification == null)
|
||||||
{
|
{
|
||||||
@ -72,6 +87,7 @@ namespace osu.Desktop.Updater
|
|||||||
await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f);
|
await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f);
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
|
updatePending = true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -113,10 +129,27 @@ namespace osu.Desktop.Updater
|
|||||||
updateManager?.Dispose();
|
updateManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class UpdateCompleteNotification : ProgressCompletionNotification
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private OsuGame game { get; set; }
|
||||||
|
|
||||||
|
public UpdateCompleteNotification(SquirrelUpdateManager updateManager)
|
||||||
|
{
|
||||||
|
Text = @"Update ready to install. Click to restart!";
|
||||||
|
|
||||||
|
Activated = () =>
|
||||||
|
{
|
||||||
|
updateManager.PrepareUpdateAsync()
|
||||||
|
.ContinueWith(_ => updateManager.Schedule(() => game.GracefullyExit()));
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class UpdateProgressNotification : ProgressNotification
|
private class UpdateProgressNotification : ProgressNotification
|
||||||
{
|
{
|
||||||
private readonly SquirrelUpdateManager updateManager;
|
private readonly SquirrelUpdateManager updateManager;
|
||||||
private OsuGame game;
|
|
||||||
|
|
||||||
public UpdateProgressNotification(SquirrelUpdateManager updateManager)
|
public UpdateProgressNotification(SquirrelUpdateManager updateManager)
|
||||||
{
|
{
|
||||||
@ -125,23 +158,12 @@ namespace osu.Desktop.Updater
|
|||||||
|
|
||||||
protected override Notification CreateCompletionNotification()
|
protected override Notification CreateCompletionNotification()
|
||||||
{
|
{
|
||||||
return new ProgressCompletionNotification
|
return new UpdateCompleteNotification(updateManager);
|
||||||
{
|
|
||||||
Text = @"Update ready to install. Click to restart!",
|
|
||||||
Activated = () =>
|
|
||||||
{
|
|
||||||
updateManager.PrepareUpdateAsync()
|
|
||||||
.ContinueWith(_ => updateManager.Schedule(() => game.GracefullyExit()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, OsuGame game)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
this.game = game;
|
|
||||||
|
|
||||||
IconContent.AddRange(new Drawable[]
|
IconContent.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
|
Loading…
Reference in New Issue
Block a user