little adjustment about load more logic

This commit is contained in:
2020-05-14 23:30:14 +08:00
parent 507b4c59f2
commit 8cbca8f290
2 changed files with 19 additions and 5 deletions

View File

@@ -9,6 +9,8 @@ namespace Pixiview.Illust
{
public partial class RelatedIllustsPage : IllustRecommendsCollectionPage
{
private const int STEP = 18;
private readonly IllustItem illustItem;
private int startIndex;
private int nextIndex;
@@ -53,15 +55,16 @@ namespace Pixiview.Illust
{
return null;
}
var ids = illustIds.Skip(startIndex).Take(18).ToArray();
nextIndex = startIndex + ids.Length;
var ids = illustIds.Skip(startIndex).Take(STEP).ToArray();
data = Stores.LoadIllustRecommendsListData(illustItem.Id, ids);
nextIndex = startIndex + STEP;
if (ids.Length == 0 || nextIndex >= illustIds.Length)
{
// done
App.DebugPrint($"download completed: {startIndex}");
return null;
startIndex = nextIndex;
}
data = Stores.LoadIllustRecommendsListData(illustItem.Id, ids);
}
return data;
}
@@ -96,6 +99,13 @@ namespace Pixiview.Illust
{
return;
}
// release
var collection = IllustCollection;
if (collection != null)
{
collection.Running = false;
IllustCollection = null;
}
startIndex = -1;
nextIndex = 0;
illustIds = null;