add channel added delete events

This commit is contained in:
Salvatore Giordano
2020-05-18 18:02:10 +02:00
parent 5a0e237a1f
commit d646dcb8c2
3 changed files with 35 additions and 5 deletions
+14 -1
View File
@@ -125,7 +125,20 @@ class ChannelsBlocState extends State<ChannelsBloc>
_subscriptions.add(client.on(EventType.channelDeleted).listen((e) {
final channel = e.channel;
_channelsController
.add(channels..removeWhere((c) => c.cid == channel.cid));
.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)));
}));
}