Skip to content

Commit

Permalink
fix total poster count
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshSolanki committed Jul 24, 2024
1 parent 0c7b892 commit d2948f1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions FoliCon/ViewModels/ProSearchResultViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using FoliCon.Modules.Extension;
using FoliCon.Modules.UI;
using FoliCon.Modules.utils;
using ImTools;
using NLog;
using Logger = NLog.Logger;

Expand Down Expand Up @@ -131,12 +132,13 @@ private async void PrepareForSearch()
await Search(SearchTitle);
SearchAgainTitle = SearchTitle;
IsBusy = false;
Index = 0;
TotalPosters = 0;
}

private async Task Search(string query, int offset = 0)
{
Logger.Trace("Search Started for {Query}, offset: {Offset}", query, offset);
Index = 0;

while (true)
{
Expand All @@ -160,7 +162,7 @@ private async Task Search(string query, int offset = 0)

private static bool HasNoResults(DArtBrowseResult searchResult)
{
return searchResult.Results?.Length == 0;
return searchResult.Results.IsNullOrEmpty();
}

private void ProcessNoResults(string query, int offset)
Expand Down Expand Up @@ -189,14 +191,14 @@ private int ProcessSearchResults(string query, DArtBrowseResult searchResult, in
foreach (var item in searchResult.Results.GetEnumeratorWithIndex())
{
ProcessResultItems(item);
if (_stopSearch)

if (!_stopSearch)
{
Logger.Debug("Search Stopped by user at {Index}", Index);
break;
continue;
}

Index++;
Logger.Debug("Search Stopped by user at {Index}", Index);
break;
}

if (!searchResult.HasMore)
Expand All @@ -216,6 +218,7 @@ private void ProcessResultItems(EnumeratorWithIndex<Result> item)
if (IsItemDownloadable(item))
{
ImageUrl.Add(new DArtImageList(item.Value.Content.Src, item.Value.Thumbs[0].Src, item.Value.Deviationid));
Index++;
}
else
{
Expand Down

0 comments on commit d2948f1

Please sign in to comment.