Pass room into SelectionPollingComponent

This commit is contained in:
smoogipoo 2021-08-19 16:40:39 +09:00
parent c31af96f1d
commit 3a1154c00e

View File

@ -3,7 +3,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
namespace osu.Game.Screens.OnlinePlay.Components namespace osu.Game.Screens.OnlinePlay.Components
@ -13,20 +12,14 @@ namespace osu.Game.Screens.OnlinePlay.Components
/// </summary> /// </summary>
public class SelectionPollingComponent : RoomPollingComponent public class SelectionPollingComponent : RoomPollingComponent
{ {
[Resolved]
private Bindable<Room> selectedRoom { get; set; }
[Resolved] [Resolved]
private IRoomManager roomManager { get; set; } private IRoomManager roomManager { get; set; }
[BackgroundDependencyLoader] private readonly Room room;
private void load()
public SelectionPollingComponent(Room room)
{ {
selectedRoom.BindValueChanged(_ => this.room = room;
{
if (IsLoaded)
PollImmediately();
});
} }
private GetRoomRequest pollReq; private GetRoomRequest pollReq;
@ -36,13 +29,13 @@ namespace osu.Game.Screens.OnlinePlay.Components
if (!API.IsLoggedIn) if (!API.IsLoggedIn)
return base.Poll(); return base.Poll();
if (selectedRoom.Value?.RoomID.Value == null) if (room.RoomID.Value == null)
return base.Poll(); return base.Poll();
var tcs = new TaskCompletionSource<bool>(); var tcs = new TaskCompletionSource<bool>();
pollReq?.Cancel(); pollReq?.Cancel();
pollReq = new GetRoomRequest(selectedRoom.Value.RoomID.Value.Value); pollReq = new GetRoomRequest(room.RoomID.Value.Value);
pollReq.Success += result => pollReq.Success += result =>
{ {