Fix playlist items showing download button briefly during initial local presence checks

This commit is contained in:
Dean Herbert
2022-09-08 16:48:43 +09:00
parent 85ce1bcea9
commit ed81297611
8 changed files with 21 additions and 8 deletions

View File

@ -17,8 +17,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
public class DownloadButton : BeatmapCardIconButton
{
public IBindable<DownloadState> State => state;
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
public Bindable<DownloadState> State { get; } = new Bindable<DownloadState>();
private readonly APIBeatmapSet beatmapSet;
@ -48,14 +47,19 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
{
base.LoadComplete();
preferNoVideo.BindValueChanged(_ => updateState());
state.BindValueChanged(_ => updateState(), true);
State.BindValueChanged(_ => updateState(), true);
FinishTransforms(true);
}
private void updateState()
{
switch (state.Value)
switch (State.Value)
{
case DownloadState.Unknown:
Action = null;
TooltipText = string.Empty;
break;
case DownloadState.Downloading:
case DownloadState.Importing:
Action = null;

View File

@ -5,6 +5,7 @@ namespace osu.Game.Online
{
public enum DownloadState
{
Unknown,
NotDownloaded,
Downloading,
Importing,

View File

@ -114,6 +114,7 @@ namespace osu.Game.Online.Rooms
switch (downloadTracker.State.Value)
{
case DownloadState.Unknown:
case DownloadState.NotDownloaded:
availability.Value = BeatmapAvailability.NotDownloaded();
break;

View File

@ -561,6 +561,10 @@ namespace osu.Game.Screens.OnlinePlay
{
switch (state.NewValue)
{
case DownloadState.Unknown:
// Ignore initial state to ensure the button doesn't briefly appear.
break;
case DownloadState.LocallyAvailable:
// Perform a local query of the beatmap by beatmap checksum, and reset the state if not matching.
if (beatmapManager.QueryBeatmap(b => b.MD5Hash == beatmap.MD5Hash) == null)

View File

@ -63,8 +63,7 @@ namespace osu.Game.Screens.Play
if (player != null)
{
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
if (importedScore != null)
state.Value = DownloadState.LocallyAvailable;
state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded;
}
state.BindValueChanged(state =>