mirror of
https://github.com/ppy/osu.git
synced 2026-05-19 10:00:42 +08:00
Clear chat state when local user changes
Closes https://github.com/ppy/osu/issues/35081.
This commit is contained in:
@@ -70,6 +70,7 @@ namespace osu.Game.Online.Chat
|
||||
[Resolved]
|
||||
private UserLookupCache users { get; set; }
|
||||
|
||||
private readonly IBindable<APIUser> localUser = new Bindable<APIUser>();
|
||||
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
|
||||
private readonly IBindableList<APIRelation> localUserBlocks = new BindableList<APIRelation>();
|
||||
private ScheduledDelegate scheduledAck;
|
||||
@@ -95,6 +96,9 @@ namespace osu.Game.Online.Chat
|
||||
chatClient.PresenceReceived += () => Schedule(initializeChannels);
|
||||
chatClient.RequestPresence();
|
||||
|
||||
localUser.BindTo(api.LocalUser);
|
||||
localUser.BindValueChanged(userChanged);
|
||||
|
||||
apiState.BindTo(api.State);
|
||||
apiState.BindValueChanged(_ => SendAck(), true);
|
||||
|
||||
@@ -102,6 +106,22 @@ namespace osu.Game.Online.Chat
|
||||
localUserBlocks.BindCollectionChanged((_, args) => Schedule(() => onBlocksChanged(args)));
|
||||
}
|
||||
|
||||
private void userChanged(ValueChangedEvent<APIUser> userChange)
|
||||
{
|
||||
if (userChange.OldValue?.Equals(userChange.NewValue) == true)
|
||||
return;
|
||||
|
||||
CurrentChannel.Value = null;
|
||||
|
||||
foreach (var joinedChannel in joinedChannels)
|
||||
joinedChannel.Joined.Value = false;
|
||||
|
||||
joinedChannels.Clear();
|
||||
// additionally clear the history of last joined channels so that the new user can't reopen the old user's channels
|
||||
// (would likely fail web-side on perms anyway, but why even get that far)
|
||||
closedChannels.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a channel or switches to the channel if already opened.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user