fix(core): only handle the channel list event if the state is success.
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -111,6 +111,9 @@ abstract class PagedValue<Key, Value> with _$PagedValue<Key, Value> {
|
||||
/// Returns `true` if the [PagedValue] is [Success].
|
||||
bool get isSuccess => this is Success<Key, Value>;
|
||||
|
||||
/// Returns `true` if the [PagedValue] is not [Success].
|
||||
bool get isNotSuccess => !isSuccess;
|
||||
|
||||
/// Returns the [PagedValue] as [Success].
|
||||
Success<Key, Value> get asSuccess {
|
||||
assert(
|
||||
|
||||
@@ -223,6 +223,9 @@ class StreamChannelListController extends PagedValueNotifier<int, Channel> {
|
||||
client.on().skip(1) // Skipping the last emitted event.
|
||||
// We only need to handle the latest events.
|
||||
.listen((event) {
|
||||
// Only handle the event if the value is in success state.
|
||||
if (value.isNotSuccess) return;
|
||||
|
||||
// Returns early if the event is already handled by the listener.
|
||||
if (eventListener?.call(event) ?? false) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user