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