mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Replace BeatmapLeaderboard
event flow with realm subscriptions
This commit is contained in:
parent
1f9318265e
commit
5dc497e949
@ -44,6 +44,8 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
Scores = null;
|
Scores = null;
|
||||||
|
|
||||||
UpdateScores();
|
UpdateScores();
|
||||||
|
if (IsLoaded)
|
||||||
|
refreshRealmSubscription();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +80,9 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; }
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RealmContextFactory realmContextFactory { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -87,9 +92,32 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
if (filterMods)
|
if (filterMods)
|
||||||
UpdateScores();
|
UpdateScores();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
scoreManager.ItemRemoved += scoreStoreChanged;
|
protected override void LoadComplete()
|
||||||
scoreManager.ItemUpdated += scoreStoreChanged;
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
refreshRealmSubscription();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IDisposable scoreSubscription;
|
||||||
|
|
||||||
|
private void refreshRealmSubscription()
|
||||||
|
{
|
||||||
|
scoreSubscription?.Dispose();
|
||||||
|
scoreSubscription = null;
|
||||||
|
|
||||||
|
if (beatmapInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
scoreSubscription = realmContextFactory.Context.All<ScoreInfo>().Where(s => s.BeatmapInfo.ID == beatmapInfo.ID).QueryAsyncWithNotifications((_, changes, ___) =>
|
||||||
|
{
|
||||||
|
if (changes == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
RefreshScores();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Reset()
|
protected override void Reset()
|
||||||
@ -212,11 +240,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (scoreManager != null)
|
scoreSubscription?.Dispose();
|
||||||
{
|
|
||||||
scoreManager.ItemRemoved -= scoreStoreChanged;
|
|
||||||
scoreManager.ItemUpdated -= scoreStoreChanged;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user