1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Use Clear to trigger async disposal

This commit is contained in:
Salman Ahmed 2024-02-05 18:39:04 +03:00
parent 9923c1b6e6
commit 858f2fc749

View File

@ -126,7 +126,11 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
case NotifyCollectionChangedAction.Remove:
Debug.Assert(args.OldItems != null);
removeRooms(args.OldItems.Cast<Room>());
if (args.OldItems.Count == roomFlow.Count)
clearRooms();
else
removeRooms(args.OldItems.Cast<Room>());
break;
}
}
@ -141,18 +145,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void removeRooms(IEnumerable<Room> rooms)
{
foreach (var room in rooms)
foreach (var r in rooms)
{
var drawableRoom = roomFlow.SingleOrDefault(d => d.Room == room);
if (drawableRoom == null)
continue;
// expire to trigger async disposal. the room still has to exist somewhere so we move it to internal content of RoomsContainer until next frame.
drawableRoom.Hide();
drawableRoom.Expire();
roomFlow.Remove(drawableRoom, false);
AddInternal(drawableRoom);
roomFlow.RemoveAll(d => d.Room == r, true);
// selection may have a lease due to being in a sub screen.
if (!SelectedRoom.Disabled)
@ -160,6 +155,15 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}
}
private void clearRooms()
{
roomFlow.Clear();
// selection may have a lease due to being in a sub screen.
if (!SelectedRoom.Disabled)
SelectedRoom.Value = null;
}
private void updateSorting()
{
foreach (var room in roomFlow)