Merge branch 'feature/null-safety' into feat/nullsafety-stream-chat

This commit is contained in:
Felix Angelov
2021-03-24 00:17:58 -05:00
committed by GitHub
65 changed files with 5509 additions and 237 deletions
+2 -1
View File
@@ -758,7 +758,8 @@ class StreamChatClient {
await _chatPersistenceClient?.updateChannelQueries(
filter,
channels.map((c) => c.channel.cid).toList(),
paginationParams?.offset == null || paginationParams.offset == 0,
clearQueryCache:
paginationParams?.offset == null || paginationParams.offset == 0,
);
state.channels = updateData.key;
@@ -100,10 +100,9 @@ abstract class ChatPersistenceClient {
/// the list of matching rows will be deleted
Future<void> updateChannelQueries(
Map<String, dynamic> filter,
List<String> cids,
// ignore: avoid_positional_boolean_parameters
bool clearQueryCache,
);
List<String> cids, {
bool clearQueryCache = false,
});
/// Remove a message by [messageId]
Future<void> deleteMessageById(String messageId) =>
@@ -121,6 +121,46 @@ class Event {
_$EventToJson(this),
topLevelFields,
);
/// Creates a copy of [Event] with specified attributes overridden.
Event copyWith({
String type,
String cid,
String channelId,
String channelType,
String connectionId,
DateTime createdAt,
OwnUser me,
User user,
Message message,
EventChannel channel,
Member member,
Reaction reaction,
int totalUnreadCount,
int unreadChannels,
bool online,
String parentId,
Map<String, dynamic> extraData,
}) =>
Event(
type: type ?? this.type,
cid: cid ?? this.cid,
connectionId: connectionId ?? this.connectionId,
createdAt: createdAt ?? this.createdAt,
me: me ?? this.me,
user: user ?? this.user,
message: message ?? this.message,
totalUnreadCount: totalUnreadCount ?? this.totalUnreadCount,
unreadChannels: unreadChannels ?? this.unreadChannels,
reaction: reaction ?? this.reaction,
online: online ?? this.online,
channel: channel ?? this.channel,
member: member ?? this.member,
channelId: channelId ?? this.channelId,
channelType: channelType ?? this.channelType,
parentId: parentId ?? this.parentId,
extraData: extraData ?? this.extraData,
);
}
/// The channel embedded in the event object
@@ -27,4 +27,16 @@ class Read {
/// Serialize to json
Map<String, dynamic> toJson() => _$ReadToJson(this);
/// Creates a copy of [Read] with specified attributes overridden.
Read copyWith({
DateTime lastRead,
User user,
int unreadMessages,
}) =>
Read(
lastRead: lastRead ?? this.lastRead,
user: user ?? this.user,
unreadMessages: unreadMessages ?? this.unreadMessages,
);
}
@@ -100,4 +100,28 @@ class User {
/// Serialize to json
Map<String, dynamic> toJson() =>
Serialization.moveFromExtraDataToRoot(_$UserToJson(this), topLevelFields);
/// Creates a copy of [User] with specified attributes overridden.
User copyWith({
String id,
String role,
DateTime createdAt,
DateTime updatedAt,
DateTime lastActive,
bool online,
Map<String, dynamic> extraData,
bool banned,
List<String> teams,
}) =>
User(
id: id ?? this.id,
role: role ?? this.role,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
lastActive: lastActive ?? this.lastActive,
online: online ?? this.online,
extraData: extraData ?? this.extraData,
banned: banned ?? this.banned,
teams: teams ?? this.teams,
);
}