@@ -1761,13 +1761,13 @@ class ChannelClientState {
|
|||||||
void _listenUserStartWatching() {
|
void _listenUserStartWatching() {
|
||||||
_subscriptions.add(
|
_subscriptions.add(
|
||||||
_channel.on(EventType.userWatchingStart).listen((event) {
|
_channel.on(EventType.userWatchingStart).listen((event) {
|
||||||
if (event.user != null) {
|
final watcher = event.user;
|
||||||
final watcher = event.user;
|
if (watcher != null) {
|
||||||
final existingWatchers = channelState.watchers ?? [];
|
final existingWatchers = channelState.watchers;
|
||||||
updateChannelState(channelState.copyWith(
|
updateChannelState(channelState.copyWith(
|
||||||
watchers: [
|
watchers: [
|
||||||
...existingWatchers,
|
...?existingWatchers,
|
||||||
watcher!,
|
watcher,
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -1778,13 +1778,12 @@ class ChannelClientState {
|
|||||||
void _listenUserStopWatching() {
|
void _listenUserStopWatching() {
|
||||||
_subscriptions.add(
|
_subscriptions.add(
|
||||||
_channel.on(EventType.userWatchingStop).listen((event) {
|
_channel.on(EventType.userWatchingStop).listen((event) {
|
||||||
if (event.user != null) {
|
final watcher = event.user;
|
||||||
final watcher = event.user;
|
if (watcher != null) {
|
||||||
final existingWatchers = channelState.watchers ?? [];
|
final existingWatchers = channelState.watchers;
|
||||||
|
|
||||||
updateChannelState(channelState.copyWith(
|
updateChannelState(channelState.copyWith(
|
||||||
watchers: existingWatchers
|
watchers: existingWatchers
|
||||||
.where((user) => user.id != watcher!.id)
|
?.where((user) => user.id != watcher.id)
|
||||||
.toList(growable: false),
|
.toList(growable: false),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -2116,9 +2115,12 @@ class ChannelClientState {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
/// Channel watchers list as a stream.
|
/// Channel watchers list as a stream.
|
||||||
Stream<List<User>?> get watchersStream => channelStateStream
|
Stream<List<User>> get watchersStream => CombineLatestStream.combine2<
|
||||||
.map((cs) => cs.watchers)
|
List<User>?, Map<String?, User?>, List<User>>(
|
||||||
.where((watchers) => watchers != null);
|
channelStateStream.map((cs) => cs.watchers),
|
||||||
|
_channel.client.state.usersStream,
|
||||||
|
(watchers, users) => watchers!.map((e) => users[e.id] ?? e).toList(),
|
||||||
|
).distinct(const ListEquality().equals);
|
||||||
|
|
||||||
/// Channel member for the current user.
|
/// Channel member for the current user.
|
||||||
Member? get currentUserMember => members.firstWhereOrNull(
|
Member? get currentUserMember => members.firstWhereOrNull(
|
||||||
|
|||||||
Reference in New Issue
Block a user