Fix watch replay button not working immediately after playing

This commit is contained in:
Dean Herbert 2022-01-14 18:03:06 +09:00
parent dea2e1fac0
commit 916b591b1b
2 changed files with 7 additions and 6 deletions

View File

@ -47,7 +47,7 @@ protected override void LoadComplete()
Downloader.DownloadBegan += downloadBegan; Downloader.DownloadBegan += downloadBegan;
Downloader.DownloadFailed += downloadFailed; Downloader.DownloadFailed += downloadFailed;
realmSubscription = realmContextFactory.Context.All<ScoreInfo>().Where(s => s.OnlineID == TrackedItem.OnlineID && !s.DeletePending).QueryAsyncWithNotifications((items, changes, ___) => realmSubscription = realmContextFactory.Context.All<ScoreInfo>().Where(s => ((s.OnlineID > 0 && s.OnlineID == TrackedItem.OnlineID) || s.Hash == TrackedItem.Hash) && !s.DeletePending).QueryAsyncWithNotifications((items, changes, ___) =>
{ {
if (items.Any()) if (items.Any())
Schedule(() => UpdateState(DownloadState.LocallyAvailable)); Schedule(() => UpdateState(DownloadState.LocallyAvailable));

View File

@ -18,6 +18,7 @@
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives; using osu.Game.IO.Archives;
using osu.Game.Online.API; using osu.Game.Online.API;
@ -1038,17 +1039,17 @@ protected virtual async Task ImportScore(Score score)
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr"); replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
} }
// the import process will re-attach managed beatmap/rulesets to this score. we don't want this for now, so create a temporary copy to import.
var importableScore = score.ScoreInfo.DeepClone();
// For the time being, online ID responses are not really useful for anything. // For the time being, online ID responses are not really useful for anything.
// In addition, the IDs provided via new (lazer) endpoints are based on a different autoincrement from legacy (stable) scores. // In addition, the IDs provided via new (lazer) endpoints are based on a different autoincrement from legacy (stable) scores.
// //
// Until we better define the server-side logic behind this, let's not store the online ID to avoid potential unique constraint // Until we better define the server-side logic behind this, let's not store the online ID to avoid potential unique constraint
// conflicts across various systems (ie. solo and multiplayer). // conflicts across various systems (ie. solo and multiplayer).
importableScore.OnlineID = -1; score.ScoreInfo.OnlineID = -1;
await scoreManager.Import(importableScore, replayReader).ConfigureAwait(false); var imported = await scoreManager.Import(score.ScoreInfo, replayReader).ConfigureAwait(false);
// detach post-import as we want to keep using the score for display in results.
score.ScoreInfo = imported.PerformRead(s => s.Detach());
} }
/// <summary> /// <summary>