[Persistence] Minor refactoring

Signed-off-by: Sahil Kumar <xdsahil@gmail.com>
This commit is contained in:
Sahil Kumar
2021-02-01 18:32:22 +05:30
parent b791040960
commit c831900484
@@ -153,17 +153,6 @@ abstract class ChatPersistenceClient {
/// Update list of channel states
Future<void> updateChannelStates(List<ChannelState> channelStates) async {
final channels = channelStates.map((it) {
return it.channel;
}).where((it) => it != null);
final reactions = channelStates.expand((it) => it.messages).expand((it) {
return [
...it.ownReactions.where((r) => r.userId != null),
...it.latestReactions.where((r) => r.userId != null)
];
}).where((it) => it != null);
final deleteReactions = deleteReactionsByMessageId(channelStates
.expand((it) => it.messages)
.map((m) => m.id)
@@ -178,6 +167,17 @@ abstract class ChatPersistenceClient {
deleteMembers,
]);
final channels = channelStates.map((it) {
return it.channel;
}).where((it) => it != null);
final reactions = channelStates.expand((it) => it.messages).expand((it) {
return [
...it.ownReactions.where((r) => r.userId != null),
...it.latestReactions.where((r) => r.userId != null)
];
}).where((it) => it != null);
final users = channelStates
.map((cs) => [
cs.channel?.createdBy,