1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Move the null check in the outside.

AddCursor() should not accept the null value.
This commit is contained in:
andy840119 2022-06-30 23:29:49 +08:00
parent a5b1f1a688
commit 48047f2e58
3 changed files with 8 additions and 7 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Extensions
/// </summary>
public static void AddCursor(this WebRequest webRequest, Cursor cursor)
{
cursor?.Properties.ForEach(x =>
cursor.Properties.ForEach(x =>
{
webRequest.AddParameter("cursor[" + x.Key + "]", (x.Value as JValue)?.ToString(CultureInfo.InvariantCulture) ?? x.Value.ToString());
});

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Framework.IO.Network;
using osu.Game.Extensions;
@ -11,9 +9,9 @@ namespace osu.Game.Online.API.Requests
public class GetNewsRequest : APIRequest<GetNewsResponse>
{
private readonly int? year;
private readonly Cursor cursor;
private readonly Cursor? cursor;
public GetNewsRequest(int? year = null, Cursor cursor = null)
public GetNewsRequest(int? year = null, Cursor? cursor = null)
{
this.year = year;
this.cursor = cursor;
@ -22,7 +20,9 @@ namespace osu.Game.Online.API.Requests
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.AddCursor(cursor);
if (cursor != null)
req.AddCursor(cursor);
if (year.HasValue)
req.AddParameter("year", year.Value.ToString());

View File

@ -112,7 +112,8 @@ namespace osu.Game.Online.API.Requests
req.AddParameter("nsfw", ExplicitContent == SearchExplicit.Show ? "true" : "false");
req.AddCursor(cursor);
if (cursor != null)
req.AddCursor(cursor);
return req;
}