-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30805 from smoogipoo/fix-playlists-enter-status
Fix playlist room status resetting on enter
- Loading branch information
Showing
4 changed files
with
70 additions
and
47 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
osu.Game.Tests/Visual/Playlists/TestScenePlaylistsRoomSubScreen.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using NUnit.Framework; | ||
using osu.Framework.Screens; | ||
using osu.Game.Online.API.Requests.Responses; | ||
using osu.Game.Online.Rooms; | ||
using osu.Game.Online.Rooms.RoomStatuses; | ||
using osu.Game.Screens.OnlinePlay.Playlists; | ||
using osu.Game.Tests.Visual.OnlinePlay; | ||
|
||
namespace osu.Game.Tests.Visual.Playlists | ||
{ | ||
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene | ||
{ | ||
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager; | ||
|
||
[Test] | ||
public void TestStatusUpdateOnEnter() | ||
{ | ||
Room room = null!; | ||
PlaylistsRoomSubScreen roomScreen = null!; | ||
|
||
AddStep("create room", () => | ||
{ | ||
RoomManager.AddRoom(room = new Room | ||
{ | ||
Name = @"Test Room", | ||
Host = new APIUser { Username = @"Host" }, | ||
Category = RoomCategory.Normal, | ||
EndDate = DateTimeOffset.Now.AddMinutes(-1) | ||
}); | ||
}); | ||
|
||
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room))); | ||
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen()); | ||
AddAssert("status is still ended", () => roomScreen.Room.Status, Is.TypeOf<RoomStatusEnded>); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using osu.Framework.IO.Network; | ||
using osu.Game.Extensions; | ||
using osu.Game.Online.API; | ||
using osu.Game.Online.Rooms.RoomStatuses; | ||
using osu.Game.Screens.OnlinePlay.Lounge.Components; | ||
|
||
namespace osu.Game.Online.Rooms | ||
|
@@ -35,25 +33,6 @@ protected override WebRequest CreateWebRequest() | |
return req; | ||
} | ||
|
||
protected override void PostProcess() | ||
{ | ||
base.PostProcess(); | ||
|
||
if (Response != null) | ||
{ | ||
// API doesn't populate status so let's do it here. | ||
foreach (var room in Response) | ||
{ | ||
if (room.EndDate != null && DateTimeOffset.Now >= room.EndDate) | ||
room.Status = new RoomStatusEnded(); | ||
else if (room.HasPassword) | ||
room.Status = new RoomStatusOpenPrivate(); | ||
else | ||
room.Status = new RoomStatusOpen(); | ||
} | ||
} | ||
} | ||
|
||
protected override string Target => "rooms"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters