mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Proof of concept realm subscriptions via Register
This commit is contained in:
@ -17,6 +17,7 @@ using osu.Game.Online.Spectator;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Scoring;
|
||||
using Realms;
|
||||
|
||||
namespace osu.Game.Screens.Spectate
|
||||
{
|
||||
@ -79,23 +80,21 @@ namespace osu.Game.Screens.Spectate
|
||||
playingUserStates.BindTo(spectatorClient.PlayingUserStates);
|
||||
playingUserStates.BindCollectionChanged(onPlayingUserStatesChanged, true);
|
||||
|
||||
realmSubscription = realmContextFactory.Register(realm =>
|
||||
realm.All<BeatmapSetInfo>()
|
||||
.Where(s => !s.DeletePending)
|
||||
.QueryAsyncWithNotifications((items, changes, ___) =>
|
||||
{
|
||||
if (changes?.InsertedIndices == null)
|
||||
return;
|
||||
|
||||
foreach (int c in changes.InsertedIndices)
|
||||
beatmapUpdated(items[c]);
|
||||
}));
|
||||
realmSubscription = realmContextFactory.Register(
|
||||
realm => realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending), beatmapsChanged);
|
||||
|
||||
foreach ((int id, var _) in userMap)
|
||||
spectatorClient.WatchUser(id);
|
||||
}));
|
||||
}
|
||||
|
||||
private void beatmapsChanged(IRealmCollection<BeatmapSetInfo> items, ChangeSet changes, Exception ___)
|
||||
{
|
||||
if (changes?.InsertedIndices == null) return;
|
||||
|
||||
foreach (int c in changes.InsertedIndices) beatmapUpdated(items[c]);
|
||||
}
|
||||
|
||||
private void beatmapUpdated(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
foreach ((int userId, _) in userMap)
|
||||
|
Reference in New Issue
Block a user