diff --git a/lib/blocs/album_list_cubit.dart b/lib/blocs/album_list_cubit.dart index 4d379a5dc..bcffcccbc 100644 --- a/lib/blocs/album_list_cubit.dart +++ b/lib/blocs/album_list_cubit.dart @@ -59,13 +59,14 @@ class AlbumListCubit extends PaginatedCubit { @override Future more() async { // Ignore calls to `more()` if there is no data, or already more coming. - if (state is! ResultsListState || - state is LoadingMoreListState || - state is DoneListState) return; + final oldState = state; + if (oldState is! ResultsListState || + oldState is LoadingMoreListState || + oldState is DoneListState) return; - final oldState = state as ResultsListState; + final resultsState = oldState as ResultsListState; - emit(LoadingMoreListState.from(oldState)); + emit(LoadingMoreListState.from(resultsState)); try { final query = _searchQuery; @@ -80,7 +81,7 @@ class AlbumListCubit extends PaginatedCubit { // changed since the request was made. if (query != _searchQuery) return; - final albums = state.results + albumsResponse.results; + final albums = resultsState.results + albumsResponse.results; final isDone = albums.length == albumsResponse.count; _nextOffset += pageSize; diff --git a/lib/blocs/member_list_cubit.dart b/lib/blocs/member_list_cubit.dart index 1ea3bccc0..596ecc333 100644 --- a/lib/blocs/member_list_cubit.dart +++ b/lib/blocs/member_list_cubit.dart @@ -59,13 +59,14 @@ class MemberListCubit extends PaginatedCubit { @override Future more() async { // Ignore calls to `more()` if there is no data, or already more coming. - if (state is! ResultsListState || - state is LoadingMoreListState || - state is DoneListState) return; + final oldState = state; + if (oldState is! ResultsListState || + oldState is LoadingMoreListState || + oldState is DoneListState) return; - final oldState = state as ResultsListState; + final resultsState = oldState as ResultsListState; - emit(LoadingMoreListState.from(oldState)); + emit(LoadingMoreListState.from(resultsState)); try { final query = _searchQuery; @@ -80,7 +81,7 @@ class MemberListCubit extends PaginatedCubit { // changed since the request was made. if (query != _searchQuery) return; - final members = oldState.results + membersResponse.results; + final members = resultsState.results + membersResponse.results; final isDone = members.length == membersResponse.count; _nextOffset += pageSize; diff --git a/lib/blocs/registrations_cubit.dart b/lib/blocs/registrations_cubit.dart index 928c52220..59e58ce91 100644 --- a/lib/blocs/registrations_cubit.dart +++ b/lib/blocs/registrations_cubit.dart @@ -39,13 +39,14 @@ class RegistrationsCubit extends PaginatedCubit { @override Future more() async { // Ignore calls to `more()` if there is no data, or already more coming. - if (state is! ResultsListState || - state is LoadingMoreListState || - state is DoneListState) return; + final oldState = state; + if (oldState is! ResultsListState || + oldState is LoadingMoreListState || + oldState is DoneListState) return; - final oldState = state as ResultsListState; + final resultsState = oldState as ResultsListState; - emit(LoadingMoreListState.from(oldState)); + emit(LoadingMoreListState.from(resultsState)); try { var listResponse = await api.getEventRegistrations( pk: eventPk, @@ -53,7 +54,7 @@ class RegistrationsCubit extends PaginatedCubit { offset: _nextOffset, ); - final registrations = state.results + listResponse.results; + final registrations = resultsState.results + listResponse.results; final isDone = registrations.length == listResponse.count; _nextOffset += pageSize;