mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Use response params in next page request
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.IO.Network;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Online.API;
|
||||
@ -16,31 +17,31 @@ namespace osu.Game.Online.Multiplayer
|
||||
private readonly int roomId;
|
||||
private readonly int playlistItemId;
|
||||
private readonly Cursor cursor;
|
||||
private readonly MultiplayerScoresSort? sort;
|
||||
private readonly IndexScoresParams indexParams;
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId, Cursor cursor = null, MultiplayerScoresSort? sort = null)
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId)
|
||||
{
|
||||
this.roomId = roomId;
|
||||
this.playlistItemId = playlistItemId;
|
||||
}
|
||||
|
||||
public IndexPlaylistScoresRequest(int roomId, int playlistItemId, [NotNull] Cursor cursor, [NotNull] IndexScoresParams indexParams)
|
||||
: this(roomId, playlistItemId)
|
||||
{
|
||||
this.cursor = cursor;
|
||||
this.sort = sort;
|
||||
this.indexParams = indexParams;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
req.AddCursor(cursor);
|
||||
|
||||
switch (sort)
|
||||
if (cursor != null)
|
||||
{
|
||||
case MultiplayerScoresSort.Ascending:
|
||||
req.AddParameter("sort", "score_asc");
|
||||
break;
|
||||
req.AddCursor(cursor);
|
||||
|
||||
case MultiplayerScoresSort.Descending:
|
||||
req.AddParameter("sort", "score_desc");
|
||||
break;
|
||||
foreach (var (key, value) in indexParams.Properties)
|
||||
req.AddParameter(key, value.ToString());
|
||||
}
|
||||
|
||||
return req;
|
||||
|
20
osu.Game/Online/Multiplayer/IndexScoresParams.cs
Normal file
20
osu.Game/Online/Multiplayer/IndexScoresParams.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// 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.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of parameters which should be passed to the index endpoint to fetch the next page.
|
||||
/// </summary>
|
||||
public class IndexScoresParams
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> Properties;
|
||||
}
|
||||
}
|
@ -29,5 +29,11 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// </summary>
|
||||
[JsonProperty("user_score")]
|
||||
public MultiplayerScore UserScore { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The parameters to be used to fetch the next page.
|
||||
/// </summary>
|
||||
[JsonProperty("params")]
|
||||
public IndexScoresParams Params { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user