From 4330507da8862d9d6cb8118bba95ac375bbd5972 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 6 Nov 2019 12:46:25 +0300 Subject: [PATCH] Use api.IsLoggedIn --- osu.Game.Tests/Visual/Online/TestSceneVotePill.cs | 12 +++++++++--- osu.Game/Overlays/Comments/VotePill.cs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs b/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs index 22e11aa464..c113bf0a04 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneVotePill.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Game.Online.API.Requests.Responses; using osu.Game.Users; using osu.Framework.MathUtils; +using osu.Game.Online.API; namespace osu.Game.Tests.Visual.Online { @@ -21,6 +22,11 @@ namespace osu.Game.Tests.Visual.Online typeof(VotePill) }; + protected override bool UseOnlineAPI => true; + + [Resolved] + private IAPIProvider api { get; set; } + private VotePill votePill; [BackgroundDependencyLoader] @@ -33,7 +39,7 @@ namespace osu.Game.Tests.Visual.Online VotesCount = 2, }; - AddStep("Log in", () => API.LocalUser.Value = new User + AddStep("Log in", () => api.LocalUser.Value = new User { Id = RNG.Next(2, 100000) }); @@ -45,7 +51,7 @@ namespace osu.Game.Tests.Visual.Online AddStep("Click", () => votePill.Click()); AddAssert("Loading", () => votePill.IsLoading); - AddStep("Log out", API.Logout); + AddStep("Log out", api.Logout); AddStep("Random comment", () => addVotePill(randomComment)); AddStep("Click", () => votePill.Click()); AddAssert("Not loading", () => !votePill.IsLoading); @@ -54,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online private Comment getUserComment() => new Comment { IsVoted = false, - UserId = API.LocalUser.Value.Id, + UserId = api.LocalUser.Value.Id, VotesCount = 10, }; diff --git a/osu.Game/Overlays/Comments/VotePill.cs b/osu.Game/Overlays/Comments/VotePill.cs index ad17264229..a5a19f5111 100644 --- a/osu.Game/Overlays/Comments/VotePill.cs +++ b/osu.Game/Overlays/Comments/VotePill.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Comments AccentColour = borderContainer.BorderColour = sideNumber.Colour = colours.GreenLight; hoverLayer.Colour = Color4.Black.Opacity(0.5f); - if (api.LocalUser.Value.Id != comment.UserId && api.LocalUser.Value.Id != 1) + if (api.LocalUser.Value.Id != comment.UserId && api.IsLoggedIn) Action = onAction; }