Fix potential race condition in song bar beatmap lookup flow

Cancelling a web request may not necessarily cancel the callbacks.

This might help with https://github.com/ppy/osu/issues/24598.
This commit is contained in:
Dean Herbert 2023-08-31 19:04:06 +09:00
parent 34b279845b
commit cf9c8120c5
1 changed files with 10 additions and 2 deletions

View File

@ -92,8 +92,16 @@ private void load()
else
{
beatmapLookupRequest = new GetBeatmapRequest(new APIBeatmap { OnlineID = beatmapId });
beatmapLookupRequest.Success += b => Beatmap.Value = new TournamentBeatmap(b);
beatmapLookupRequest.Failure += _ => Beatmap.Value = null;
beatmapLookupRequest.Success += b =>
{
if (lastBeatmapId == beatmapId)
Beatmap.Value = new TournamentBeatmap(b);
};
beatmapLookupRequest.Failure += _ =>
{
if (lastBeatmapId == beatmapId)
Beatmap.Value = null;
};
API.Queue(beatmapLookupRequest);
}
}