fixes #413: channels bloc does not perform the call if pagination is ended

This commit is contained in:
Salvatore Giordano
2021-05-05 12:52:05 +02:00
parent 7ece5c7504
commit 86698614f6
@@ -95,7 +95,12 @@ class ChannelsBlocState extends State<ChannelsBloc>
}) async {
final client = StreamChatCore.of(context).client;
if (_paginationEnded || _queryChannelsLoadingController.value == true) {
final clear = paginationParams == null ||
paginationParams.offset == null ||
paginationParams.offset == 0;
if ((!clear && _paginationEnded) ||
_queryChannelsLoadingController.value == true) {
return;
}
@@ -104,9 +109,6 @@ class ChannelsBlocState extends State<ChannelsBloc>
}
try {
final clear = paginationParams == null ||
paginationParams.offset == null ||
paginationParams.offset == 0;
final oldChannels = List<Channel>.from(channels ?? []);
var newChannels = <Channel>[];
await for (final channels in client.queryChannels(
@@ -148,7 +150,13 @@ class ChannelsBlocState extends State<ChannelsBloc>
final client = StreamChatCore.of(context).client;
if (!widget.lockChannelsOrder) {
_subscriptions.add(client.on(EventType.messageNew).listen((e) {
_subscriptions.add(client
.on(
EventType.messageNew,
EventType.notificationAddedToChannel,
EventType.notificationMessageNew,
)
.listen((e) {
final newChannels = List<Channel>.from(channels ?? []);
final index = newChannels.indexWhere((c) => c.cid == e.cid);
if (index != -1) {