Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show an ongoing operation when checking for updates #30953

Merged

Conversation

peppy
Copy link
Member

@peppy peppy commented Dec 3, 2024

Addresses #30950.

Thought this would be a quick one, but during testing I noticed an unobserved exception could lead to a failure (even on master). Also, if the settings overlay was closed during the update check, the Schedule in the ContinueWith would not run (as the settings panel is not present).

I've fixed both issues by using the (relatively unused) SynchronizationContext presence, which means the continuation will be automatically scheduled back to the update thread (since it was triggered from that thread).

Can be tested using some iteration of:

diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs
index c114e3a8d0..d9aa12fa46 100644
--- a/osu.Game/Updater/UpdateManager.cs
+++ b/osu.Game/Updater/UpdateManager.cs
@@ -26,9 +26,7 @@ public partial class UpdateManager : CompositeDrawable
         /// <summary>
         /// Whether this UpdateManager should be or is capable of checking for updates.
         /// </summary>
-        public bool CanCheckForUpdate => game.IsDeployedBuild &&
-                                         // only implementations will actually check for updates.
-                                         GetType() != typeof(UpdateManager);
+        public bool CanCheckForUpdate => true;
 
         [Resolved]
         private OsuConfigManager config { get; set; } = null!;
@@ -70,13 +68,15 @@ protected override void LoadComplete()
 
         public async Task<bool> CheckForUpdateAsync()
         {
+            await Task.Delay(3000).ConfigureAwait(false);
+
             if (!CanCheckForUpdate)
                 return false;
 
             Task<bool> waitTask;
 
             lock (updateTaskLock)
-                waitTask = (updateCheckTask ??= PerformUpdateCheck());
+                waitTask = updateCheckTask ??= PerformUpdateCheck();
 
             bool hasUpdates = await waitTask.ConfigureAwait(false);
 

@peppy peppy changed the title Show an ongoing operation when checking for updates Addresses https://github.com/ppy/osu/discussions/30950. Show an ongoing operation when checking for updates Dec 3, 2024
@smoogipoo smoogipoo merged commit f09d8f0 into ppy:master Dec 3, 2024
10 checks passed
@peppy peppy deleted the notification-while-chedcking-for-updates branch December 5, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants