mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 10:23:20 +08:00
Merge pull request #30895 from peppy/watch-replay-reliability
Fix watch replay button sometimes not loading the replay on first click
This commit is contained in:
commit
d0e80ce982
@ -559,7 +559,11 @@ namespace osu.Game.Beatmaps
|
|||||||
// If we seem to be missing files, now is a good time to re-fetch.
|
// If we seem to be missing files, now is a good time to re-fetch.
|
||||||
bool missingFiles = beatmapInfo.BeatmapSet?.Files.Count == 0;
|
bool missingFiles = beatmapInfo.BeatmapSet?.Files.Count == 0;
|
||||||
|
|
||||||
if (refetch || beatmapInfo.IsManaged || missingFiles)
|
if (beatmapInfo.IsManaged)
|
||||||
|
{
|
||||||
|
beatmapInfo = beatmapInfo.Detach();
|
||||||
|
}
|
||||||
|
else if (refetch || missingFiles)
|
||||||
{
|
{
|
||||||
Guid id = beatmapInfo.ID;
|
Guid id = beatmapInfo.ID;
|
||||||
beatmapInfo = Realm.Run(r => r.Find<BeatmapInfo>(id)?.Detach()) ?? beatmapInfo;
|
beatmapInfo = Realm.Run(r => r.Find<BeatmapInfo>(id)?.Detach()) ?? beatmapInfo;
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Scoring
|
|||||||
/// Perform a lookup query on available <see cref="ScoreInfo"/>s.
|
/// Perform a lookup query on available <see cref="ScoreInfo"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="query">The query.</param>
|
/// <param name="query">The query.</param>
|
||||||
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
/// <returns>The first result for the provided query in its detached form, or null if no results were found.</returns>
|
||||||
public ScoreInfo? Query(Expression<Func<ScoreInfo, bool>> query)
|
public ScoreInfo? Query(Expression<Func<ScoreInfo, bool>> query)
|
||||||
{
|
{
|
||||||
return Realm.Run(r => r.All<ScoreInfo>().FirstOrDefault(query)?.Detach());
|
return Realm.Run(r => r.All<ScoreInfo>().FirstOrDefault(query)?.Detach());
|
||||||
@ -88,8 +88,14 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
ScoreInfo? databasedScoreInfo = null;
|
ScoreInfo? databasedScoreInfo = null;
|
||||||
|
|
||||||
if (originalScoreInfo is ScoreInfo scoreInfo && !string.IsNullOrEmpty(scoreInfo.Hash))
|
if (originalScoreInfo is ScoreInfo scoreInfo)
|
||||||
databasedScoreInfo = Query(s => s.Hash == scoreInfo.Hash);
|
{
|
||||||
|
if (scoreInfo.IsManaged)
|
||||||
|
return scoreInfo.Detach();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(scoreInfo.Hash))
|
||||||
|
databasedScoreInfo = Query(s => s.Hash == scoreInfo.Hash);
|
||||||
|
}
|
||||||
|
|
||||||
if (originalScoreInfo.OnlineID > 0)
|
if (originalScoreInfo.OnlineID > 0)
|
||||||
databasedScoreInfo ??= Query(s => s.OnlineID == originalScoreInfo.OnlineID);
|
databasedScoreInfo ??= Query(s => s.OnlineID == originalScoreInfo.OnlineID);
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly Func<Task<ScoreInfo>>? importFailedScore;
|
private readonly Func<Task<ScoreInfo>>? importFailedScore;
|
||||||
|
|
||||||
private ScoreInfo? importedScore;
|
private Live<ScoreInfo>? importedScore;
|
||||||
|
|
||||||
private DownloadButton button = null!;
|
private DownloadButton button = null!;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Play
|
|||||||
switch (state.Value)
|
switch (state.Value)
|
||||||
{
|
{
|
||||||
case DownloadState.LocallyAvailable:
|
case DownloadState.LocallyAvailable:
|
||||||
game?.PresentScore(importedScore, ScorePresentType.Gameplay);
|
game?.PresentScore(importedScore?.Value, ScorePresentType.Gameplay);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.NotDownloaded:
|
case DownloadState.NotDownloaded:
|
||||||
@ -65,7 +65,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
Task.Run(importFailedScore).ContinueWith(t =>
|
Task.Run(importFailedScore).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
|
importedScore = realm.Run<Live<ScoreInfo>?>(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.ToLive(realm));
|
||||||
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
|
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
|
||||||
}).FireAndForget();
|
}).FireAndForget();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.Detach());
|
importedScore = realm.Run(r => r.Find<ScoreInfo>(player.Score.ScoreInfo.ID)?.ToLive(realm));
|
||||||
state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded;
|
state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (state.NewValue != DownloadState.LocallyAvailable) return;
|
if (state.NewValue != DownloadState.LocallyAvailable) return;
|
||||||
|
|
||||||
if (importedScore != null) scoreManager.Export(importedScore);
|
if (importedScore != null) scoreManager.Export(importedScore.Value);
|
||||||
|
|
||||||
this.state.ValueChanged -= exportWhenReady;
|
this.state.ValueChanged -= exportWhenReady;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user