From dd86751ca8bb085de5a6ae46a777b02b2be533ae Mon Sep 17 00:00:00 2001 From: Insomniachi Date: Wed, 20 Mar 2024 21:21:19 +0530 Subject: [PATCH] fix crashes --- Totoro.Core/Services/MyAnimeList/MyAnimeListService.cs | 10 +++++++++- Totoro.Core/ViewModels/WatchViewModel.cs | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Totoro.Core/Services/MyAnimeList/MyAnimeListService.cs b/Totoro.Core/Services/MyAnimeList/MyAnimeListService.cs index b5eb5bf..e67d975 100644 --- a/Totoro.Core/Services/MyAnimeList/MyAnimeListService.cs +++ b/Totoro.Core/Services/MyAnimeList/MyAnimeListService.cs @@ -173,7 +173,15 @@ public async IAsyncEnumerable GetFillers(long id) var offset = 0; do { - response = await _jikan.GetAnimeEpisodesAsync(animeId.MyAnimeList.Value, currentPage++); + try + { + response = await _jikan.GetAnimeEpisodesAsync(animeId.MyAnimeList.Value, currentPage++); + } + catch + { + yield break; + } + foreach (var item in response.Data.Select((x, index) => (x, index)).Where(x => x.x.Filler == true).Select(x => x.index + 1 + offset)) { yield return item; diff --git a/Totoro.Core/ViewModels/WatchViewModel.cs b/Totoro.Core/ViewModels/WatchViewModel.cs index b16650b..023a550 100644 --- a/Totoro.Core/ViewModels/WatchViewModel.cs +++ b/Totoro.Core/ViewModels/WatchViewModel.cs @@ -118,11 +118,11 @@ public WatchViewModel(IPluginFactory providerFactory, this.ObservableForProperty(x => x.Anime, x => x) .WhereNotNull() + .ObserveOn(RxApp.MainThreadScheduler) .Do(async model => await UpdateMetaData(model.Id)) .SelectMany(model => Find(model.Id, model.Title)) .Where(x => x is not (null, null)) .Log(this, "Selected Anime", x => $"{x.Sub.Title}") - .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(async x => { var hasSubDub = x is { Dub: { }, Sub: { } }; @@ -621,6 +621,7 @@ private void SetAnime(long id) _animeService.GetInformation(id) .ToObservable() + .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(async anime => { _anime = anime;