From 0a4eb0a1711ba3f5f71f98ac752776b4343a94c7 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 23 Mar 2022 16:25:51 +0530 Subject: [PATCH 1/2] feat(ui): only handle the latest events in channelEventSubscription Signed-off-by: xsahil03x --- .../lib/src/stream_channel_list_controller.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 3b7342e5..7fa3b226 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -220,8 +220,8 @@ class StreamChannelListController extends PagedValueNotifier { _unsubscribeFromChannelListEvents(); } - _channelEventSubscription = client.on().listen((event) { - print('event.type: ${event.type}'); + _channelEventSubscription = client.on().skip(1) // skip the initial event + .listen((event) { // Returns early if the event is already handled by the listener. if (eventListener?.call(event) ?? false) return; From 67dad76e46d90cd23d761cfb997ea2fc01b83fea Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Wed, 23 Mar 2022 16:33:20 +0530 Subject: [PATCH 2/2] feat(ui): improve the message for skipping the event. Signed-off-by: xsahil03x --- .../lib/src/stream_channel_list_controller.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 7fa3b226..9fe5594c 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -220,8 +220,10 @@ class StreamChannelListController extends PagedValueNotifier { _unsubscribeFromChannelListEvents(); } - _channelEventSubscription = client.on().skip(1) // skip the initial event - .listen((event) { + _channelEventSubscription = + client.on().skip(1) // Skipping the last emitted event. + // We only need to handle the latest events. + .listen((event) { // Returns early if the event is already handled by the listener. if (eventListener?.call(event) ?? false) return;