Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
insomniachi committed May 12, 2023
1 parent 0f69f4b commit f1703bb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Totoro.Core/ViewModels/WatchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public override async Task OnNavigatedTo(IReadOnlyDictionary<string, object> par

public override async Task OnNavigatedFrom()
{
MediaPlayer.Dispose();
MediaPlayer?.Dispose();
NativeMethods.AllowSleep();
if (_videoStreamResolver is IAsyncDisposable ad)
{
Expand Down Expand Up @@ -497,9 +497,13 @@ private async Task TrySetAnime(string url, string title)
return;
}

_anime = await _animeService.GetInformation(id.Value);
_episodeMetadata = await _myAnimeListService.GetEpisodes(id.Value);
SetAnime(_anime);
_animeService.GetInformation(id.Value)
.Subscribe(async anime =>
{
_anime = anime;
_episodeMetadata = await _myAnimeListService.GetEpisodes(id.Value);
SetAnime(_anime);
}, RxApp.DefaultExceptionHandler.OnError);
}

private async Task TrySetAnime(string title)
Expand All @@ -512,9 +516,13 @@ private async Task TrySetAnime(string title)
return;
}

_anime = await _animeService.GetInformation(id.Value);
_episodeMetadata = await _myAnimeListService.GetEpisodes(id.Value);
SetAnime(_anime);
_animeService.GetInformation(id.Value)
.Subscribe(async anime =>
{
_anime = anime;
_episodeMetadata = await _myAnimeListService.GetEpisodes(id.Value);
SetAnime(_anime);
}, RxApp.DefaultExceptionHandler.OnError);
}

private async Task<long?> TryGetId(string title)
Expand Down

0 comments on commit f1703bb

Please sign in to comment.