update event listeners

This commit is contained in:
Salvatore Giordano
2020-05-22 16:33:47 +02:00
parent c080c3f712
commit 24eca0a9c3
2 changed files with 20 additions and 21 deletions
+3 -21
View File
@@ -122,31 +122,13 @@ class ChannelsBlocState extends State<ChannelsBloc>
}
}));
_subscriptions.add(client.on(EventType.channelDeleted).listen((e) {
_subscriptions.add(client
.on(EventType.channelDeleted, EventType.notificationRemovedFromChannel)
.listen((e) {
final channel = e.channel;
_channelsController
.add(List.from(channels..removeWhere((c) => c.cid == channel.cid)));
}));
_subscriptions
.add(client.on(EventType.notificationAddedToChannel).listen((e) async {
final channelModel = e.channel;
final channel = Channel(
client,
channelModel.type,
channelModel.id,
channelModel.extraData,
);
await channel.watch();
_channelsController.add(List.from(channels..insert(0, channel)));
}));
_subscriptions.add(
client.on(EventType.notificationRemovedFromChannel).listen((e) async {
final channelModel = e.channel;
_channelsController.add(
List.from(channels..removeWhere((c) => c.cid == channelModel.cid)));
}));
}
@override