Merge pull request #24235 from AkiSakurai/toplocalrank

Compute the top local rank directly without an expensive detach call
This commit is contained in:
Dean Herbert 2023-07-16 12:14:56 +09:00 committed by GitHub
commit 2d51aa21b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -75,8 +75,7 @@ void localScoresChanged(IRealmCollection<ScoreInfo> sender, ChangeSet? changes)
if (changes?.HasCollectionChanges() == false)
return;
ScoreInfo? topScore = sender.Detach().OrderByTotalScore().FirstOrDefault();
ScoreInfo? topScore = sender.MaxBy(info => (info.TotalScore, -info.Date.UtcDateTime.Ticks));
updateable.Rank = topScore?.Rank;
updateable.Alpha = topScore != null ? 1 : 0;
}