Show a notification if checking for updates via button and there are none available

This commit is contained in:
Dean Herbert
2020-10-06 13:00:02 +09:00
parent 798dc9bc25
commit 22b0105d62
4 changed files with 41 additions and 14 deletions

View File

@ -57,25 +57,28 @@ namespace osu.Game.Updater
private readonly object updateTaskLock = new object();
private Task updateCheckTask;
private Task<bool> updateCheckTask;
public async Task CheckForUpdateAsync()
public async Task<bool> CheckForUpdateAsync()
{
if (!CanCheckForUpdate)
return;
Task waitTask;
Task<bool> waitTask;
lock (updateTaskLock)
waitTask = (updateCheckTask ??= PerformUpdateCheck());
await waitTask;
bool hasUpdates = await waitTask;
lock (updateTaskLock)
updateCheckTask = null;
return hasUpdates;
}
protected virtual Task PerformUpdateCheck() => Task.CompletedTask;
/// <summary>
/// Performs an asynchronous check for application updates.
/// </summary>
/// <returns>Whether any update is waiting. May return true if an error occured (there is potentially an update available).</returns>
protected virtual Task<bool> PerformUpdateCheck() => Task.FromResult(false);
private class UpdateCompleteNotification : SimpleNotification
{