mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Simplify offset calculation
This commit is contained in:
@ -8,21 +8,21 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T>
|
||||
{
|
||||
private readonly int offset;
|
||||
private readonly int limit;
|
||||
private readonly int page;
|
||||
private readonly int itemsPerPage;
|
||||
|
||||
protected PaginatedAPIRequest(int offset, int limit)
|
||||
protected PaginatedAPIRequest(int page, int itemsPerPage)
|
||||
{
|
||||
this.offset = offset;
|
||||
this.limit = limit;
|
||||
this.page = page;
|
||||
this.itemsPerPage = itemsPerPage;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
req.AddParameter("offset", offset.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddParameter("limit", limit.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddParameter("offset", (page * itemsPerPage).ToString(CultureInfo.InvariantCulture));
|
||||
req.AddParameter("limit", itemsPerPage.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
return req;
|
||||
}
|
||||
|
Reference in New Issue
Block a user