1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Merge pull request #26081 from peppy/fix-spectate-users

Fix "spectate" button not always being clickable in online users list
This commit is contained in:
Bartłomiej Dach 2023-12-23 14:52:54 +01:00 committed by GitHub
commit 881a91ed69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -81,6 +81,21 @@ namespace osu.Game.Tests.Visual.Online
AddStep("End watching user presence", () => metadataClient.EndWatchingUserPresence()); AddStep("End watching user presence", () => metadataClient.EndWatchingUserPresence());
} }
[Test]
public void TestUserWasPlayingBeforeWatchingUserPresence()
{
AddStep("User began playing", () => spectatorClient.SendStartPlay(streamingUser.Id, 0));
AddStep("Begin watching user presence", () => metadataClient.BeginWatchingUserPresence());
AddStep("Add online user", () => metadataClient.UserPresenceUpdated(streamingUser.Id, new UserPresence { Status = UserStatus.Online, Activity = new UserActivity.ChoosingBeatmap() }));
AddUntilStep("Panel loaded", () => currentlyOnline.ChildrenOfType<UserGridPanel>().FirstOrDefault()?.User.Id == 2);
AddAssert("Spectate button enabled", () => currentlyOnline.ChildrenOfType<PurpleRoundedButton>().First().Enabled.Value, () => Is.True);
AddStep("User finished playing", () => spectatorClient.SendEndPlay(streamingUser.Id));
AddAssert("Spectate button disabled", () => currentlyOnline.ChildrenOfType<PurpleRoundedButton>().First().Enabled.Value, () => Is.False);
AddStep("Remove playing user", () => metadataClient.UserPresenceUpdated(streamingUser.Id, null));
AddStep("End watching user presence", () => metadataClient.EndWatchingUserPresence());
}
internal partial class TestUserLookupCache : UserLookupCache internal partial class TestUserLookupCache : UserLookupCache
{ {
private static readonly string[] usernames = private static readonly string[] usernames =

View File

@ -6,6 +6,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions; using osu.Framework.Extensions;
@ -218,6 +219,7 @@ namespace osu.Game.Overlays.Dashboard
{ {
panel.Anchor = Anchor.TopCentre; panel.Anchor = Anchor.TopCentre;
panel.Origin = Anchor.TopCentre; panel.Origin = Anchor.TopCentre;
panel.CanSpectate.Value = playingUsers.Contains(user.Id);
}); });
public partial class OnlineUserPanel : CompositeDrawable, IFilterable public partial class OnlineUserPanel : CompositeDrawable, IFilterable