mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 09:03:00 +08:00
Pagination
-> `PaginationParameters
This commit is contained in:
parent
96d4369cc8
commit
c858ec2483
@ -13,7 +13,7 @@ namespace osu.Game.Online.API.Requests
|
||||
|
||||
private readonly BeatmapSetType type;
|
||||
|
||||
public GetUserBeatmapsRequest(long userId, BeatmapSetType type, Pagination pagination)
|
||||
public GetUserBeatmapsRequest(long userId, BeatmapSetType type, PaginationParameters pagination)
|
||||
: base(pagination)
|
||||
{
|
||||
this.userId = userId;
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
private readonly long userId;
|
||||
|
||||
public GetUserKudosuHistoryRequest(long userId, Pagination pagination)
|
||||
public GetUserKudosuHistoryRequest(long userId, PaginationParameters pagination)
|
||||
: base(pagination)
|
||||
{
|
||||
this.userId = userId;
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
private readonly long userId;
|
||||
|
||||
public GetUserMostPlayedBeatmapsRequest(long userId, Pagination pagination)
|
||||
public GetUserMostPlayedBeatmapsRequest(long userId, PaginationParameters pagination)
|
||||
: base(pagination)
|
||||
{
|
||||
this.userId = userId;
|
||||
|
@ -10,7 +10,7 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
private readonly long userId;
|
||||
|
||||
public GetUserRecentActivitiesRequest(long userId, Pagination pagination)
|
||||
public GetUserRecentActivitiesRequest(long userId, PaginationParameters pagination)
|
||||
: base(pagination)
|
||||
{
|
||||
this.userId = userId;
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Online.API.Requests
|
||||
private readonly ScoreType type;
|
||||
private readonly RulesetInfo ruleset;
|
||||
|
||||
public GetUserScoresRequest(long userId, ScoreType type, Pagination pagination, RulesetInfo ruleset = null)
|
||||
public GetUserScoresRequest(long userId, ScoreType type, PaginationParameters pagination, RulesetInfo ruleset = null)
|
||||
: base(pagination)
|
||||
{
|
||||
this.userId = userId;
|
||||
|
@ -8,9 +8,9 @@ namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public abstract class PaginatedAPIRequest<T> : APIRequest<T> where T : class
|
||||
{
|
||||
private readonly Pagination pagination;
|
||||
private readonly PaginationParameters pagination;
|
||||
|
||||
protected PaginatedAPIRequest(Pagination pagination)
|
||||
protected PaginatedAPIRequest(PaginationParameters pagination)
|
||||
{
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace osu.Game.Online.API.Requests
|
||||
/// <summary>
|
||||
/// Represents a pagination data used for <see cref="PaginatedAPIRequest{T}"/>.
|
||||
/// </summary>
|
||||
public readonly struct Pagination
|
||||
public readonly struct PaginationParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting point of the request.
|
||||
@ -18,21 +18,21 @@ namespace osu.Game.Online.API.Requests
|
||||
/// </summary>
|
||||
public int Limit { get; }
|
||||
|
||||
public Pagination(int offset, int limit)
|
||||
public PaginationParameters(int offset, int limit)
|
||||
{
|
||||
Offset = offset;
|
||||
Limit = limit;
|
||||
}
|
||||
|
||||
public Pagination(int limit)
|
||||
public PaginationParameters(int limit)
|
||||
: this(0, limit)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="Pagination"/> of the next number of items defined by <paramref name="limit"/> after this.
|
||||
/// Returns a <see cref="PaginationParameters"/> of the next number of items defined by <paramref name="limit"/> after this.
|
||||
/// </summary>
|
||||
/// <param name="limit">The limit of the next pagination.</param>
|
||||
public Pagination TakeNext(int limit) => new Pagination(Offset + Limit, limit);
|
||||
public PaginationParameters TakeNext(int limit) => new PaginationParameters(Offset + Limit, limit);
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest(Pagination pagination) =>
|
||||
protected override APIRequest<List<APIBeatmapSet>> CreateRequest(PaginationParameters pagination) =>
|
||||
new GetUserBeatmapsRequest(User.Value.Id, type, pagination);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIBeatmapSet model) => model.OnlineID > 0
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
|
||||
protected override int GetCount(APIUser user) => user.BeatmapPlayCountsCount;
|
||||
|
||||
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest(Pagination pagination) =>
|
||||
protected override APIRequest<List<APIUserMostPlayedBeatmap>> CreateRequest(PaginationParameters pagination) =>
|
||||
new GetUserMostPlayedBeatmapsRequest(User.Value.Id, pagination);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIUserMostPlayedBeatmap mostPlayed) =>
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
|
||||
{
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIKudosuHistory>> CreateRequest(Pagination pagination)
|
||||
protected override APIRequest<List<APIKudosuHistory>> CreateRequest(PaginationParameters pagination)
|
||||
=> new GetUserKudosuHistoryRequest(User.Value.Id, pagination);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIKudosuHistory item) => new DrawableKudosuHistoryItem(item);
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
protected Pagination? CurrentPage { get; private set; }
|
||||
protected PaginationParameters? CurrentPage { get; private set; }
|
||||
|
||||
protected ReverseChildIDFillFlowContainer<Drawable> ItemsContainer { get; private set; }
|
||||
|
||||
@ -111,7 +111,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
loadCancellation = new CancellationTokenSource();
|
||||
|
||||
CurrentPage = CurrentPage?.TakeNext(ItemsPerPage) ?? new Pagination(InitialItemsCount);
|
||||
CurrentPage = CurrentPage?.TakeNext(ItemsPerPage) ?? new PaginationParameters(InitialItemsCount);
|
||||
|
||||
retrievalRequest = CreateRequest(CurrentPage.Value);
|
||||
retrievalRequest.Success += UpdateItems;
|
||||
@ -151,7 +151,7 @@ namespace osu.Game.Overlays.Profile.Sections
|
||||
{
|
||||
}
|
||||
|
||||
protected abstract APIRequest<List<TModel>> CreateRequest(Pagination pagination);
|
||||
protected abstract APIRequest<List<TModel>> CreateRequest(PaginationParameters pagination);
|
||||
|
||||
protected abstract Drawable CreateDrawableItem(TModel model);
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
base.OnItemsReceived(items);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIScore>> CreateRequest(Pagination pagination) =>
|
||||
protected override APIRequest<List<APIScore>> CreateRequest(PaginationParameters pagination) =>
|
||||
new GetUserScoresRequest(User.Value.Id, type, pagination);
|
||||
|
||||
private int drawableItemIndex;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
ItemsContainer.Spacing = new Vector2(0, 8);
|
||||
}
|
||||
|
||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest(Pagination pagination) =>
|
||||
protected override APIRequest<List<APIRecentActivity>> CreateRequest(PaginationParameters pagination) =>
|
||||
new GetUserRecentActivitiesRequest(User.Value.Id, pagination);
|
||||
|
||||
protected override Drawable CreateDrawableItem(APIRecentActivity model) => new DrawableRecentActivity(model);
|
||||
|
Loading…
Reference in New Issue
Block a user