add channel added delete events
This commit is contained in:
@@ -78,6 +78,19 @@ void main() async {
|
|||||||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A',
|
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VwZXItYmFuZC05In0.0L6lGoeLwkz0aZRUcpZKsvaXtNEDHBcezVTZ0oPq40A',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// final client = Client(
|
||||||
|
// 'qk4nn7rpcn75',
|
||||||
|
// logLevel: Level.INFO,
|
||||||
|
// showLocalNotification: Platform.isAndroid ? showLocalNotification : null,
|
||||||
|
// persistenceEnabled: true,
|
||||||
|
// baseURL: '127.0.0.1:3030',
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// await client.setUser(
|
||||||
|
// User(id: 'super-band-9'),
|
||||||
|
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoic3VwZXItdHJhbXAtOSJ9.BbcxsR3FsK9c1q1ijhbBWvlXRwRpZ1RoHMKscKWZklk',
|
||||||
|
// );
|
||||||
|
|
||||||
_initNotifications(client);
|
_initNotifications(client);
|
||||||
|
|
||||||
runApp(MyApp(client));
|
runApp(MyApp(client));
|
||||||
|
|||||||
@@ -125,7 +125,20 @@ class ChannelsBlocState extends State<ChannelsBloc>
|
|||||||
_subscriptions.add(client.on(EventType.channelDeleted).listen((e) {
|
_subscriptions.add(client.on(EventType.channelDeleted).listen((e) {
|
||||||
final channel = e.channel;
|
final channel = e.channel;
|
||||||
_channelsController
|
_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)));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,14 +149,18 @@ class StreamChannelState extends State<StreamChannel> {
|
|||||||
initialData: widget.channel.state != null,
|
initialData: widget.channel.state != null,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData || !snapshot.data) {
|
if (!snapshot.hasData || !snapshot.data) {
|
||||||
return Scaffold(
|
return Container(
|
||||||
body: Center(
|
height: 30,
|
||||||
|
child: Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
return Center(
|
return Container(
|
||||||
child: Text(snapshot.error),
|
height: 30,
|
||||||
|
child: Center(
|
||||||
|
child: Text(snapshot.error),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return widget.child;
|
return widget.child;
|
||||||
|
|||||||
Reference in New Issue
Block a user