1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-18 11:43:22 +08:00

Rename fields from State to Presence when presence is involved

This commit is contained in:
Dean Herbert 2025-01-17 16:25:48 +09:00
parent a51938f4e9
commit 3bb4b0c2b8
No known key found for this signature in database
5 changed files with 41 additions and 41 deletions

View File

@ -46,7 +46,7 @@ namespace osu.Game.Online
private readonly Bindable<bool> notifyOnFriendPresenceChange = new BindableBool(); private readonly Bindable<bool> notifyOnFriendPresenceChange = new BindableBool();
private readonly IBindableList<APIRelation> friends = new BindableList<APIRelation>(); private readonly IBindableList<APIRelation> friends = new BindableList<APIRelation>();
private readonly IBindableDictionary<int, UserPresence> friendStates = new BindableDictionary<int, UserPresence>(); private readonly IBindableDictionary<int, UserPresence> friendPresences = new BindableDictionary<int, UserPresence>();
private readonly HashSet<APIUser> onlineAlertQueue = new HashSet<APIUser>(); private readonly HashSet<APIUser> onlineAlertQueue = new HashSet<APIUser>();
private readonly HashSet<APIUser> offlineAlertQueue = new HashSet<APIUser>(); private readonly HashSet<APIUser> offlineAlertQueue = new HashSet<APIUser>();
@ -63,8 +63,8 @@ namespace osu.Game.Online
friends.BindTo(api.Friends); friends.BindTo(api.Friends);
friends.BindCollectionChanged(onFriendsChanged, true); friends.BindCollectionChanged(onFriendsChanged, true);
friendStates.BindTo(metadataClient.FriendStates); friendPresences.BindTo(metadataClient.FriendPresences);
friendStates.BindCollectionChanged(onFriendStatesChanged, true); friendPresences.BindCollectionChanged(onFriendPresenceChanged, true);
} }
protected override void Update() protected override void Update()
@ -85,7 +85,7 @@ namespace osu.Game.Online
if (friend.TargetUser is not APIUser user) if (friend.TargetUser is not APIUser user)
continue; continue;
if (friendStates.TryGetValue(friend.TargetID, out _)) if (friendPresences.TryGetValue(friend.TargetID, out _))
markUserOnline(user); markUserOnline(user);
} }
@ -105,7 +105,7 @@ namespace osu.Game.Online
} }
} }
private void onFriendStatesChanged(object? sender, NotifyDictionaryChangedEventArgs<int, UserPresence> e) private void onFriendPresenceChanged(object? sender, NotifyDictionaryChangedEventArgs<int, UserPresence> e)
{ {
switch (e.Action) switch (e.Action)
{ {

View File

@ -40,17 +40,17 @@ namespace osu.Game.Online.Metadata
/// <summary> /// <summary>
/// The <see cref="UserPresence"/> information about the current user. /// The <see cref="UserPresence"/> information about the current user.
/// </summary> /// </summary>
public abstract UserPresence LocalUserState { get; } public abstract UserPresence LocalUserPresence { get; }
/// <summary> /// <summary>
/// Dictionary keyed by user ID containing all of the <see cref="UserPresence"/> information about currently online users received from the server. /// Dictionary keyed by user ID containing all of the <see cref="UserPresence"/> information about currently online users received from the server.
/// </summary> /// </summary>
public abstract IBindableDictionary<int, UserPresence> UserStates { get; } public abstract IBindableDictionary<int, UserPresence> UserPresences { get; }
/// <summary> /// <summary>
/// Dictionary keyed by user ID containing all of the <see cref="UserPresence"/> information about currently online friends received from the server. /// Dictionary keyed by user ID containing all of the <see cref="UserPresence"/> information about currently online friends received from the server.
/// </summary> /// </summary>
public abstract IBindableDictionary<int, UserPresence> FriendStates { get; } public abstract IBindableDictionary<int, UserPresence> FriendPresences { get; }
/// <inheritdoc/> /// <inheritdoc/>
public abstract Task UpdateActivity(UserActivity? activity); public abstract Task UpdateActivity(UserActivity? activity);

View File

@ -23,14 +23,14 @@ namespace osu.Game.Online.Metadata
public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence; public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence;
private readonly BindableBool isWatchingUserPresence = new BindableBool(); private readonly BindableBool isWatchingUserPresence = new BindableBool();
public override UserPresence LocalUserState => localUserState; public override UserPresence LocalUserPresence => localUserPresence;
private UserPresence localUserState; private UserPresence localUserPresence;
public override IBindableDictionary<int, UserPresence> UserStates => userStates; public override IBindableDictionary<int, UserPresence> UserPresences => userPresences;
private readonly BindableDictionary<int, UserPresence> userStates = new BindableDictionary<int, UserPresence>(); private readonly BindableDictionary<int, UserPresence> userPresences = new BindableDictionary<int, UserPresence>();
public override IBindableDictionary<int, UserPresence> FriendStates => friendStates; public override IBindableDictionary<int, UserPresence> FriendPresences => friendPresences;
private readonly BindableDictionary<int, UserPresence> friendStates = new BindableDictionary<int, UserPresence>(); private readonly BindableDictionary<int, UserPresence> friendPresences = new BindableDictionary<int, UserPresence>();
public override IBindable<DailyChallengeInfo?> DailyChallengeInfo => dailyChallengeInfo; public override IBindable<DailyChallengeInfo?> DailyChallengeInfo => dailyChallengeInfo;
private readonly Bindable<DailyChallengeInfo?> dailyChallengeInfo = new Bindable<DailyChallengeInfo?>(); private readonly Bindable<DailyChallengeInfo?> dailyChallengeInfo = new Bindable<DailyChallengeInfo?>();
@ -110,10 +110,10 @@ namespace osu.Game.Online.Metadata
Schedule(() => Schedule(() =>
{ {
isWatchingUserPresence.Value = false; isWatchingUserPresence.Value = false;
userStates.Clear(); userPresences.Clear();
friendStates.Clear(); friendPresences.Clear();
dailyChallengeInfo.Value = null; dailyChallengeInfo.Value = null;
localUserState = default; localUserPresence = default;
}); });
return; return;
} }
@ -208,16 +208,16 @@ namespace osu.Game.Online.Metadata
if (presence?.Status != null) if (presence?.Status != null)
{ {
if (userId == api.LocalUser.Value.OnlineID) if (userId == api.LocalUser.Value.OnlineID)
localUserState = presence.Value; localUserPresence = presence.Value;
else else
userStates[userId] = presence.Value; userPresences[userId] = presence.Value;
} }
else else
{ {
if (userId == api.LocalUser.Value.OnlineID) if (userId == api.LocalUser.Value.OnlineID)
localUserState = default; localUserPresence = default;
else else
userStates.Remove(userId); userPresences.Remove(userId);
} }
}); });
@ -229,9 +229,9 @@ namespace osu.Game.Online.Metadata
Schedule(() => Schedule(() =>
{ {
if (presence?.Status != null) if (presence?.Status != null)
friendStates[userId] = presence.Value; friendPresences[userId] = presence.Value;
else else
friendStates.Remove(userId); friendPresences.Remove(userId);
}); });
return Task.CompletedTask; return Task.CompletedTask;
@ -256,7 +256,7 @@ namespace osu.Game.Online.Metadata
throw new OperationCanceledException(); throw new OperationCanceledException();
// must be scheduled before any remote calls to avoid mis-ordering. // must be scheduled before any remote calls to avoid mis-ordering.
Schedule(() => userStates.Clear()); Schedule(() => userPresences.Clear());
Debug.Assert(connection != null); Debug.Assert(connection != null);
await connection.InvokeAsync(nameof(IMetadataServer.EndWatchingUserPresence)).ConfigureAwait(false); await connection.InvokeAsync(nameof(IMetadataServer.EndWatchingUserPresence)).ConfigureAwait(false);
Logger.Log($@"{nameof(OnlineMetadataClient)} stopped watching user presence", LoggingTarget.Network); Logger.Log($@"{nameof(OnlineMetadataClient)} stopped watching user presence", LoggingTarget.Network);

View File

@ -106,7 +106,7 @@ namespace osu.Game.Overlays.Dashboard
{ {
base.LoadComplete(); base.LoadComplete();
onlineUsers.BindTo(metadataClient.UserStates); onlineUsers.BindTo(metadataClient.UserPresences);
onlineUsers.BindCollectionChanged(onUserUpdated, true); onlineUsers.BindCollectionChanged(onUserUpdated, true);
playingUsers.BindTo(spectatorClient.PlayingUsers); playingUsers.BindTo(spectatorClient.PlayingUsers);

View File

@ -19,14 +19,14 @@ namespace osu.Game.Tests.Visual.Metadata
public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence; public override IBindable<bool> IsWatchingUserPresence => isWatchingUserPresence;
private readonly BindableBool isWatchingUserPresence = new BindableBool(); private readonly BindableBool isWatchingUserPresence = new BindableBool();
public override UserPresence LocalUserState => localUserState; public override UserPresence LocalUserPresence => localUserPresence;
private UserPresence localUserState; private UserPresence localUserPresence;
public override IBindableDictionary<int, UserPresence> UserStates => userStates; public override IBindableDictionary<int, UserPresence> UserPresences => userPresences;
private readonly BindableDictionary<int, UserPresence> userStates = new BindableDictionary<int, UserPresence>(); private readonly BindableDictionary<int, UserPresence> userPresences = new BindableDictionary<int, UserPresence>();
public override IBindableDictionary<int, UserPresence> FriendStates => friendStates; public override IBindableDictionary<int, UserPresence> FriendPresences => friendPresences;
private readonly BindableDictionary<int, UserPresence> friendStates = new BindableDictionary<int, UserPresence>(); private readonly BindableDictionary<int, UserPresence> friendPresences = new BindableDictionary<int, UserPresence>();
public override Bindable<DailyChallengeInfo?> DailyChallengeInfo => dailyChallengeInfo; public override Bindable<DailyChallengeInfo?> DailyChallengeInfo => dailyChallengeInfo;
private readonly Bindable<DailyChallengeInfo?> dailyChallengeInfo = new Bindable<DailyChallengeInfo?>(); private readonly Bindable<DailyChallengeInfo?> dailyChallengeInfo = new Bindable<DailyChallengeInfo?>();
@ -50,9 +50,9 @@ namespace osu.Game.Tests.Visual.Metadata
{ {
if (isWatchingUserPresence.Value) if (isWatchingUserPresence.Value)
{ {
userStates.TryGetValue(api.LocalUser.Value.Id, out var localUserPresence); userPresences.TryGetValue(api.LocalUser.Value.Id, out var localUserPresence);
localUserPresence = localUserPresence with { Activity = activity }; localUserPresence = localUserPresence with { Activity = activity };
userStates[api.LocalUser.Value.Id] = localUserPresence; userPresences[api.LocalUser.Value.Id] = localUserPresence;
} }
return Task.CompletedTask; return Task.CompletedTask;
@ -62,9 +62,9 @@ namespace osu.Game.Tests.Visual.Metadata
{ {
if (isWatchingUserPresence.Value) if (isWatchingUserPresence.Value)
{ {
userStates.TryGetValue(api.LocalUser.Value.Id, out var localUserPresence); userPresences.TryGetValue(api.LocalUser.Value.Id, out var localUserPresence);
localUserPresence = localUserPresence with { Status = status }; localUserPresence = localUserPresence with { Status = status };
userStates[api.LocalUser.Value.Id] = localUserPresence; userPresences[api.LocalUser.Value.Id] = localUserPresence;
} }
return Task.CompletedTask; return Task.CompletedTask;
@ -77,16 +77,16 @@ namespace osu.Game.Tests.Visual.Metadata
if (presence?.Status != null) if (presence?.Status != null)
{ {
if (userId == api.LocalUser.Value.OnlineID) if (userId == api.LocalUser.Value.OnlineID)
localUserState = presence.Value; localUserPresence = presence.Value;
else else
userStates[userId] = presence.Value; userPresences[userId] = presence.Value;
} }
else else
{ {
if (userId == api.LocalUser.Value.OnlineID) if (userId == api.LocalUser.Value.OnlineID)
localUserState = default; localUserPresence = default;
else else
userStates.Remove(userId); userPresences.Remove(userId);
} }
} }
@ -96,9 +96,9 @@ namespace osu.Game.Tests.Visual.Metadata
public override Task FriendPresenceUpdated(int userId, UserPresence? presence) public override Task FriendPresenceUpdated(int userId, UserPresence? presence)
{ {
if (presence.HasValue) if (presence.HasValue)
friendStates[userId] = presence.Value; friendPresences[userId] = presence.Value;
else else
friendStates.Remove(userId); friendPresences.Remove(userId);
return Task.CompletedTask; return Task.CompletedTask;
} }