mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Pass room into SelectionPollingComponent
This commit is contained in:
parent
c31af96f1d
commit
3a1154c00e
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Components
|
||||
@ -13,20 +12,14 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
/// </summary>
|
||||
public class SelectionPollingComponent : RoomPollingComponent
|
||||
{
|
||||
[Resolved]
|
||||
private Bindable<Room> selectedRoom { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IRoomManager roomManager { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private readonly Room room;
|
||||
|
||||
public SelectionPollingComponent(Room room)
|
||||
{
|
||||
selectedRoom.BindValueChanged(_ =>
|
||||
{
|
||||
if (IsLoaded)
|
||||
PollImmediately();
|
||||
});
|
||||
this.room = room;
|
||||
}
|
||||
|
||||
private GetRoomRequest pollReq;
|
||||
@ -36,13 +29,13 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
if (!API.IsLoggedIn)
|
||||
return base.Poll();
|
||||
|
||||
if (selectedRoom.Value?.RoomID.Value == null)
|
||||
if (room.RoomID.Value == null)
|
||||
return base.Poll();
|
||||
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
pollReq?.Cancel();
|
||||
pollReq = new GetRoomRequest(selectedRoom.Value.RoomID.Value.Value);
|
||||
pollReq = new GetRoomRequest(room.RoomID.Value.Value);
|
||||
|
||||
pollReq.Success += result =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user