mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Show a notification if checking for updates via button and there are none available
This commit is contained in:
@ -4,9 +4,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Overlays.Settings.Sections.Maintenance;
|
||||
using osu.Game.Updater;
|
||||
|
||||
@ -21,6 +23,9 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
|
||||
private SettingsButton checkForUpdatesButton;
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(Storage storage, OsuConfigManager config, OsuGame game)
|
||||
{
|
||||
@ -30,7 +35,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
Bindable = config.GetBindable<ReleaseStream>(OsuSetting.ReleaseStream),
|
||||
});
|
||||
|
||||
if (updateManager?.CanCheckForUpdate == true)
|
||||
//if (updateManager?.CanCheckForUpdate == true)
|
||||
{
|
||||
Add(checkForUpdatesButton = new SettingsButton
|
||||
{
|
||||
@ -38,7 +43,19 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
Action = () =>
|
||||
{
|
||||
checkForUpdatesButton.Enabled.Value = false;
|
||||
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() => checkForUpdatesButton.Enabled.Value = true));
|
||||
Task.Run(updateManager.CheckForUpdateAsync).ContinueWith(t => Schedule(() =>
|
||||
{
|
||||
if (!t.Result)
|
||||
{
|
||||
notifications.Post(new SimpleNotification
|
||||
{
|
||||
Text = $"You are running the latest release ({game.Version})",
|
||||
Icon = FontAwesome.Solid.CheckCircle,
|
||||
});
|
||||
}
|
||||
|
||||
checkForUpdatesButton.Enabled.Value = true;
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user