mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Another fix for #2
This commit is contained in:
parent
59f2654f11
commit
b610e5488d
@ -54,7 +54,8 @@ public async override Task<PageResponse<Shout>> HandleResponse(HttpResponseMessa
|
|||||||
var shouts = new List<Shout>();
|
var shouts = new List<Shout>();
|
||||||
if (shoutsToken != null && pageresponse.TotalItems > 0)
|
if (shoutsToken != null && pageresponse.TotalItems > 0)
|
||||||
{
|
{
|
||||||
if (pageresponse.TotalItems == 1)
|
if (pageresponse.Page == pageresponse.TotalPages
|
||||||
|
&& pageresponse.TotalItems % pageresponse.PageSize == 1)
|
||||||
{
|
{
|
||||||
// array notation isn't used on the api if there is only one shout.
|
// array notation isn't used on the api if there is only one shout.
|
||||||
shouts.Add(Shout.ParseJToken(shoutsToken));
|
shouts.Add(Shout.ParseJToken(shoutsToken));
|
||||||
|
@ -57,7 +57,8 @@ public async override Task<PageResponse<Shout>> HandleResponse(HttpResponseMessa
|
|||||||
var shouts = new List<Shout>();
|
var shouts = new List<Shout>();
|
||||||
if (shoutsToken != null && pageresponse.TotalItems > 0)
|
if (shoutsToken != null && pageresponse.TotalItems > 0)
|
||||||
{
|
{
|
||||||
if (pageresponse.TotalItems == 1)
|
if (pageresponse.Page == pageresponse.TotalPages
|
||||||
|
&& pageresponse.TotalItems % pageresponse.PageSize == 1)
|
||||||
{
|
{
|
||||||
// array notation isn't used on the api if there is only one shout.
|
// array notation isn't used on the api if there is only one shout.
|
||||||
shouts.Add(Shout.ParseJToken(shoutsToken));
|
shouts.Add(Shout.ParseJToken(shoutsToken));
|
||||||
|
@ -23,6 +23,7 @@ public PageResponse()
|
|||||||
public int Page { get; set; }
|
public int Page { get; set; }
|
||||||
public int TotalPages { get; set; }
|
public int TotalPages { get; set; }
|
||||||
public int TotalItems { get; set; }
|
public int TotalItems { get; set; }
|
||||||
|
public int PageSize { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -112,6 +113,9 @@ public void AddPageInfoFromJToken(JToken attrToken)
|
|||||||
|
|
||||||
var totalItems = attrToken.Value<string>("total");
|
var totalItems = attrToken.Value<string>("total");
|
||||||
TotalItems = !string.IsNullOrWhiteSpace(totalItems) ? Convert.ToInt32(totalItems) : 1;
|
TotalItems = !string.IsNullOrWhiteSpace(totalItems) ? Convert.ToInt32(totalItems) : 1;
|
||||||
|
|
||||||
|
var pagesize = attrToken.Value<string>("perPage");
|
||||||
|
PageSize = !string.IsNullOrWhiteSpace(pagesize) ? Convert.ToInt32(pagesize) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// {"@attr": {
|
// {"@attr": {
|
||||||
|
Loading…
Reference in New Issue
Block a user