1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:13:21 +08:00

Fix current room being set to null when parted

This commit is contained in:
smoogipoo 2019-02-06 13:59:11 +09:00
parent a9aa22c97b
commit 3207983a1c

View File

@ -25,6 +25,8 @@ namespace osu.Game.Screens.Multi
public Bindable<Room> CurrentRoom { get; } = new Bindable<Room>();
private Room joinedRoom;
[Resolved]
private APIAccess api { get; set; }
@ -50,8 +52,7 @@ namespace osu.Game.Screens.Multi
{
update(room, result);
addRoom(room);
CurrentRoom.Value = room;
joinRoom(room);
RoomsUpdated?.Invoke();
@ -79,7 +80,7 @@ namespace osu.Game.Screens.Multi
currentJoinRoomRequest = new JoinRoomRequest(room, api.LocalUser.Value);
currentJoinRoomRequest.Success += () =>
{
CurrentRoom.Value = room;
joinRoom(room);
onSuccess?.Invoke(room);
};
@ -92,13 +93,19 @@ namespace osu.Game.Screens.Multi
api.Queue(currentJoinRoomRequest);
}
private void joinRoom(Room room)
{
CurrentRoom.Value = room;
joinedRoom = room;
}
public void PartRoom()
{
if (CurrentRoom.Value == null)
if (joinedRoom == null)
return;
api.Queue(new PartRoomRequest(CurrentRoom.Value, api.LocalUser.Value));
CurrentRoom.Value = null;
api.Queue(new PartRoomRequest(joinedRoom, api.LocalUser.Value));
joinedRoom = null;
}
public void UpdateRooms(List<Room> newRooms)