1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-23 23:33:18 +08:00

Add loading in case cache lookup takes longer than expected

This commit is contained in:
Layendan 2025-02-06 17:23:06 -07:00
parent b7483b9442
commit 6769a74c92

View File

@ -8,6 +8,7 @@ using osu.Framework.Extensions;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -19,6 +20,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{ {
private readonly Room room; private readonly Room room;
private LoadingLayer loading = null!;
[Resolved] [Resolved]
private RealmAccess realmAccess { get; set; } = null!; private RealmAccess realmAccess { get; set; } = null!;
@ -39,6 +42,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
{ {
BackgroundColour = colours.Gray5; BackgroundColour = colours.Gray5;
Add(loading = new LoadingLayer(true, false));
Action = () => Action = () =>
{ {
int[] ids = room.Playlist.Select(item => item.Beatmap.OnlineID).Where(onlineId => onlineId > 0).ToArray(); int[] ids = room.Playlist.Select(item => item.Beatmap.OnlineID).Where(onlineId => onlineId > 0).ToArray();
@ -49,6 +54,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
return; return;
} }
Enabled.Value = false;
loading.Show();
beatmapLookupCache.GetBeatmapsAsync(ids).ContinueWith(task => Schedule(() => beatmapLookupCache.GetBeatmapsAsync(ids).ContinueWith(task => Schedule(() =>
{ {
var beatmaps = task.GetResultSafely().Where(item => item?.BeatmapSet != null).ToList(); var beatmaps = task.GetResultSafely().Where(item => item?.BeatmapSet != null).ToList();
@ -71,6 +78,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
notifications?.Post(new SimpleNotification { Text = $"Updated playlist: {room.Name}" }); notifications?.Post(new SimpleNotification { Text = $"Updated playlist: {room.Name}" });
}); });
} }
loading.Hide();
Enabled.Value = true;
}), TaskContinuationOptions.OnlyOnRanToCompletion); }), TaskContinuationOptions.OnlyOnRanToCompletion);
}; };
} }