fix(ui): Fix adding anime or manga

This commit is contained in:
PapaTutuWawa 2023-02-08 20:25:20 +01:00
parent e12b9a0c72
commit 5cd3909c4d

View File

@ -59,18 +59,12 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
// Add it to the cache
_animes.add(event.data);
if (event.data.state == state.animeFilterState ||
state.animeFilterState == MediumTrackingState.all) {
emit(
state.copyWith(
animes: List.from([
...state.animes,
event.data,
]),
animes: _getFilteredAnime(),
),
);
}
}
Future<void> _onMangaAdded(MangaAddedEvent event, Emitter<AnimeListState> emit) async {
// Add the manga to the database
@ -79,18 +73,12 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
// Add it to the cache
_mangas.add(event.data);
if (event.data.state == state.mangaFilterState ||
state.mangaFilterState == MediumTrackingState.all) {
emit(
state.copyWith(
mangas: List.from([
...state.mangas,
event.data,
]),
mangas: _getFilteredManga(),
),
);
}
}
Future<void> _onAnimeIncremented(AnimeEpisodeIncrementedEvent event, Emitter<AnimeListState> emit) async {
final index = state.animes.indexWhere((item) => item.id == event.id);