mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 07:42:55 +08:00
Fix playlist room status resetting on enter
This commit is contained in:
parent
fe8e9d455a
commit
7018672275
@ -1,12 +1,10 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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 @@ namespace osu.Game.Online.Rooms
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.IO.Serialization.Converters;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -264,6 +265,18 @@ namespace osu.Game.Online.Rooms
|
||||
set => SetField(ref availability, value);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void onDeserialised(StreamingContext context)
|
||||
{
|
||||
// API doesn't populate status so let's do it here.
|
||||
if (EndDate != null && DateTimeOffset.Now >= EndDate)
|
||||
Status = new RoomStatusEnded();
|
||||
else if (HasPassword)
|
||||
Status = new RoomStatusOpenPrivate();
|
||||
else
|
||||
Status = new RoomStatusOpen();
|
||||
}
|
||||
|
||||
[JsonProperty("id")]
|
||||
private long? roomId;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user