private void LoadChapters(IMangaRecord manga)
{
if (manga == null)
return;
var scraper = CurrentScraper;
OperationInProgress = true;
CurrentActionText = "Loading chapters ...";
_requestQueue.Add(
() => scraper.GetAvailableChapters(manga),
(r, e) =>
{
var results = r as IEnumerable<IChapterRecord>;
if (e == null && results != null)
{
lock (_syncRoot)
{
// just replace collection -> this is easier than removing and then adding records
Chapters =
new AsyncObservableCollection<ChapterViewModel>(
results.Select(ch => new ChapterViewModel(ch, ServiceLocator.Instance.GetService<Library.ILibraryManager>().GetDownloadInfo(ch, true))));
OnPropertyChanged(() => Chapters);
}
}
}
);
}