fix rebuild message list view
This commit is contained in:
@@ -70,8 +70,11 @@ class Channel {
|
||||
true;
|
||||
|
||||
/// Returns true if the channel is muted as a stream
|
||||
Stream<bool>? get isMutedStream => _client.state.userStream.map((event) =>
|
||||
event!.channelMutes.any((element) => element.channel.cid == cid) == true);
|
||||
Stream<bool>? get isMutedStream => _client.state.userStream
|
||||
.map((event) =>
|
||||
event!.channelMutes.any((element) => element.channel.cid == cid) ==
|
||||
true)
|
||||
.distinct();
|
||||
|
||||
/// True if the channel is a group
|
||||
bool get isGroup => memberCount != 2;
|
||||
@@ -1604,7 +1607,7 @@ class ChannelClientState {
|
||||
/// Channel message list as a stream
|
||||
Stream<List<Message>?> get messagesStream => channelStateStream
|
||||
.map((cs) => cs.messages)
|
||||
.distinct((prev, next) => const ListEquality().equals(prev, next));
|
||||
.distinct(const ListEquality().equals);
|
||||
|
||||
/// Channel pinned message list
|
||||
List<Message>? get pinnedMessages => _channelState.pinnedMessages.toList();
|
||||
@@ -1634,7 +1637,7 @@ class ChannelClientState {
|
||||
_channel.client.state.usersStream,
|
||||
(members, users) =>
|
||||
members!.map((e) => e!.copyWith(user: users[e.user!.id])).toList(),
|
||||
);
|
||||
).distinct(const ListEquality().equals);
|
||||
|
||||
/// Channel watcher count
|
||||
int? get watcherCount => _channelState.watcherCount;
|
||||
@@ -1804,7 +1807,9 @@ class ChannelClientState {
|
||||
List<User> get typingEvents => _typingEventsController.value;
|
||||
|
||||
/// Channel related typing users stream
|
||||
Stream<List<User>> get typingEventsStream => _typingEventsController.stream;
|
||||
Stream<List<User>> get typingEventsStream =>
|
||||
_typingEventsController.stream.distinct(const ListEquality().equals);
|
||||
|
||||
final BehaviorSubject<List<User>> _typingEventsController =
|
||||
BehaviorSubject.seeded([]);
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ class StreamChatClient {
|
||||
/// This notifies the connection status of the websocket connection.
|
||||
/// Listen to this to get notified when the websocket tries to reconnect.
|
||||
Stream<ConnectionStatus> get wsConnectionStatusStream =>
|
||||
_wsConnectionStatusController.stream;
|
||||
_wsConnectionStatusController.stream.distinct();
|
||||
|
||||
/// The current user token
|
||||
String? token;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/models/user.dart';
|
||||
|
||||
@@ -6,7 +7,7 @@ part 'member.g.dart';
|
||||
/// The class that contains the information about the user membership
|
||||
/// in a channel
|
||||
@JsonSerializable()
|
||||
class Member {
|
||||
class Member extends Equatable {
|
||||
/// Constructor used for json serialization
|
||||
Member({
|
||||
this.user,
|
||||
@@ -98,4 +99,19 @@ class Member {
|
||||
|
||||
/// Serialize to json
|
||||
Map<String, dynamic> toJson() => _$MemberToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
user,
|
||||
inviteAcceptedAt,
|
||||
inviteRejectedAt,
|
||||
invited,
|
||||
role,
|
||||
userId,
|
||||
isModerator,
|
||||
banned,
|
||||
shadowBanned,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:stream_chat/src/models/serialization.dart';
|
||||
|
||||
@@ -5,7 +6,7 @@ part 'user.g.dart';
|
||||
|
||||
/// The class that defines the user model
|
||||
@JsonSerializable()
|
||||
class User {
|
||||
class User extends Equatable {
|
||||
/// Constructor used for json serialization
|
||||
User({
|
||||
required this.id,
|
||||
@@ -125,4 +126,17 @@ class User {
|
||||
banned: banned ?? this.banned,
|
||||
teams: teams ?? this.teams,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
role,
|
||||
teams,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
lastActive,
|
||||
online,
|
||||
banned,
|
||||
extraData,
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user