fix persistence abstract class
This commit is contained in:
@@ -180,8 +180,11 @@ abstract class ChatPersistenceClient {
|
|||||||
.map((m) => m.id)
|
.map((m) => m.id)
|
||||||
.toList(growable: false));
|
.toList(growable: false));
|
||||||
|
|
||||||
|
final cleanedChannelStates =
|
||||||
|
channelStates.where((it) => it.channel != null);
|
||||||
|
|
||||||
final deleteMembers = deleteMembersByCids(
|
final deleteMembers = deleteMembersByCids(
|
||||||
channelStates.map((it) => it.channel!.cid).toList(growable: false),
|
cleanedChannelStates.map((it) => it.channel!.cid).toList(growable: false),
|
||||||
);
|
);
|
||||||
|
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
@@ -189,19 +192,21 @@ abstract class ChatPersistenceClient {
|
|||||||
deleteMembers,
|
deleteMembers,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final channels = channelStates
|
final channels = cleanedChannelStates
|
||||||
.map((it) => it.channel)
|
.map((it) => it.channel)
|
||||||
.where((it) => it != null) as Iterable<ChannelModel>;
|
.where((it) => it != null) as Iterable<ChannelModel>;
|
||||||
|
|
||||||
final reactions = channelStates.expand((it) => it.messages).expand((it) => [
|
final reactions =
|
||||||
if (it.ownReactions != null)
|
cleanedChannelStates.expand((it) => it.messages).expand((it) => [
|
||||||
...it.ownReactions?.where((r) => r.userId != null) ?? <Reaction>[],
|
if (it.ownReactions != null)
|
||||||
if (it.latestReactions != null)
|
...it.ownReactions?.where((r) => r.userId != null) ??
|
||||||
...it.latestReactions?.where((r) => r.userId != null) ??
|
<Reaction>[],
|
||||||
<Reaction>[],
|
if (it.latestReactions != null)
|
||||||
]);
|
...it.latestReactions?.where((r) => r.userId != null) ??
|
||||||
|
<Reaction>[],
|
||||||
|
]);
|
||||||
|
|
||||||
final users = channelStates
|
final users = cleanedChannelStates
|
||||||
.map((cs) => [
|
.map((cs) => [
|
||||||
cs.channel?.createdBy,
|
cs.channel?.createdBy,
|
||||||
...cs.messages
|
...cs.messages
|
||||||
@@ -219,25 +224,25 @@ abstract class ChatPersistenceClient {
|
|||||||
.expand((it) => it)
|
.expand((it) => it)
|
||||||
.where((it) => it != null) as Iterable<User>;
|
.where((it) => it != null) as Iterable<User>;
|
||||||
|
|
||||||
final updateMessagesFuture = channelStates.map((it) {
|
final updateMessagesFuture = cleanedChannelStates.map((it) {
|
||||||
final cid = it.channel!.cid;
|
final cid = it.channel!.cid;
|
||||||
final messages = it.messages;
|
final messages = it.messages;
|
||||||
return updateMessages(cid, messages.toList(growable: false));
|
return updateMessages(cid, messages.toList(growable: false));
|
||||||
}).toList(growable: false);
|
}).toList(growable: false);
|
||||||
|
|
||||||
final updatePinnedMessagesFuture = channelStates.map((it) {
|
final updatePinnedMessagesFuture = cleanedChannelStates.map((it) {
|
||||||
final cid = it.channel!.cid;
|
final cid = it.channel!.cid;
|
||||||
final messages = it.pinnedMessages;
|
final messages = it.pinnedMessages;
|
||||||
return updatePinnedMessages(cid, messages.toList(growable: false));
|
return updatePinnedMessages(cid, messages.toList(growable: false));
|
||||||
}).toList(growable: false);
|
}).toList(growable: false);
|
||||||
|
|
||||||
final updateReadsFuture = channelStates.map((it) {
|
final updateReadsFuture = cleanedChannelStates.map((it) {
|
||||||
final cid = it.channel!.cid;
|
final cid = it.channel!.cid;
|
||||||
final reads = it.read;
|
final reads = it.read;
|
||||||
return updateReads(cid, reads.toList(growable: false));
|
return updateReads(cid, reads.toList(growable: false));
|
||||||
}).toList(growable: false);
|
}).toList(growable: false);
|
||||||
|
|
||||||
final updateMembersFuture = channelStates.map((it) {
|
final updateMembersFuture = cleanedChannelStates.map((it) {
|
||||||
final cid = it.channel!.cid;
|
final cid = it.channel!.cid;
|
||||||
final members = it.members;
|
final members = it.members;
|
||||||
return updateMembers(cid, members.toList(growable: false));
|
return updateMembers(cid, members.toList(growable: false));
|
||||||
|
|||||||
Reference in New Issue
Block a user