use a map for channels in client

This commit is contained in:
Salvatore Giordano
2020-04-06 16:46:00 +02:00
parent 713a3dd07d
commit fa2be8397d
+5 -1
View File
@@ -1,11 +1,14 @@
import 'dart:async';
import 'package:rxdart/rxdart.dart';
import 'package:stream_chat/stream_chat.dart';
class ChannelsBloc {
final Client client;
StreamSubscription _newMessagesSubscription;
ChannelsBloc(this.client) {
client.on(EventType.messageNew).listen((e) {
_newMessagesSubscription = client.on(EventType.messageNew).listen((e) {
final newChannels = List<Channel>.from(channels ?? []);
final index = newChannels.indexWhere((c) => c.cid == e.cid);
if (index > 0) {
@@ -80,5 +83,6 @@ class ChannelsBloc {
void dispose() {
_channelsController.close();
_queryChannelsLoadingController.close();
_newMessagesSubscription.cancel();
}
}