feat(llc): add crud for pinned message reactions
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -170,9 +170,15 @@ abstract class ChatPersistenceClient {
|
|||||||
/// Updates the reactions data with the new [reactions] data
|
/// Updates the reactions data with the new [reactions] data
|
||||||
Future<void> updateReactions(List<Reaction> reactions);
|
Future<void> updateReactions(List<Reaction> reactions);
|
||||||
|
|
||||||
|
/// Updates the pinned message reactions data with the new [reactions] data
|
||||||
|
Future<void> updatePinnedMessageReactions(List<Reaction> reactions);
|
||||||
|
|
||||||
/// Deletes all the reactions by [messageIds]
|
/// Deletes all the reactions by [messageIds]
|
||||||
Future<void> deleteReactionsByMessageId(List<String> messageIds);
|
Future<void> deleteReactionsByMessageId(List<String> messageIds);
|
||||||
|
|
||||||
|
/// Deletes all the pinned messages reactions by [messageIds]
|
||||||
|
Future<void> deletePinnedMessageReactionsByMessageId(List<String> messageIds);
|
||||||
|
|
||||||
/// Deletes all the members by channel [cids]
|
/// Deletes all the members by channel [cids]
|
||||||
Future<void> deleteMembersByCids(List<String> cids);
|
Future<void> deleteMembersByCids(List<String> cids);
|
||||||
|
|
||||||
@@ -187,6 +193,12 @@ abstract class ChatPersistenceClient {
|
|||||||
.map((m) => m.id)
|
.map((m) => m.id)
|
||||||
.toList(growable: false));
|
.toList(growable: false));
|
||||||
|
|
||||||
|
final deletePinnedMessageReactions =
|
||||||
|
deletePinnedMessageReactionsByMessageId(channelStates
|
||||||
|
.expand((it) => it.pinnedMessages)
|
||||||
|
.map((m) => m.id)
|
||||||
|
.toList(growable: false));
|
||||||
|
|
||||||
final cleanedChannelStates =
|
final cleanedChannelStates =
|
||||||
channelStates.where((it) => it.channel != null);
|
channelStates.where((it) => it.channel != null);
|
||||||
|
|
||||||
@@ -196,6 +208,7 @@ abstract class ChatPersistenceClient {
|
|||||||
|
|
||||||
await Future.wait([
|
await Future.wait([
|
||||||
deleteReactions,
|
deleteReactions,
|
||||||
|
deletePinnedMessageReactions,
|
||||||
deleteMembers,
|
deleteMembers,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -211,6 +224,16 @@ abstract class ChatPersistenceClient {
|
|||||||
])
|
])
|
||||||
.withNullifyer;
|
.withNullifyer;
|
||||||
|
|
||||||
|
final pinnedMessageReactions = cleanedChannelStates
|
||||||
|
.expand((it) => it.pinnedMessages)
|
||||||
|
.expand((it) => [
|
||||||
|
if (it.ownReactions != null)
|
||||||
|
...it.ownReactions!.where((r) => r.userId != null),
|
||||||
|
if (it.latestReactions != null)
|
||||||
|
...it.latestReactions!.where((r) => r.userId != null),
|
||||||
|
])
|
||||||
|
.withNullifyer;
|
||||||
|
|
||||||
final users = cleanedChannelStates
|
final users = cleanedChannelStates
|
||||||
.map((cs) => [
|
.map((cs) => [
|
||||||
cs.channel?.createdBy,
|
cs.channel?.createdBy,
|
||||||
@@ -261,6 +284,9 @@ abstract class ChatPersistenceClient {
|
|||||||
updateUsers(users.toList(growable: false)),
|
updateUsers(users.toList(growable: false)),
|
||||||
updateChannels(channels.toList(growable: false)),
|
updateChannels(channels.toList(growable: false)),
|
||||||
updateReactions(reactions.toList(growable: false)),
|
updateReactions(reactions.toList(growable: false)),
|
||||||
|
updatePinnedMessageReactions(
|
||||||
|
pinnedMessageReactions.toList(growable: false),
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ class TestPersistenceClient extends ChatPersistenceClient {
|
|||||||
Future<void> deleteReactionsByMessageId(List<String> messageIds) =>
|
Future<void> deleteReactionsByMessageId(List<String> messageIds) =>
|
||||||
Future.value();
|
Future.value();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deletePinnedMessageReactionsByMessageId(
|
||||||
|
List<String> messageIds) =>
|
||||||
|
Future.value();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> disconnect({bool flush = false}) => throw UnimplementedError();
|
Future<void> disconnect({bool flush = false}) => throw UnimplementedError();
|
||||||
|
|
||||||
@@ -116,6 +121,10 @@ class TestPersistenceClient extends ChatPersistenceClient {
|
|||||||
@override
|
@override
|
||||||
Future<void> updateReactions(List<Reaction> reactions) => Future.value();
|
Future<void> updateReactions(List<Reaction> reactions) => Future.value();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updatePinnedMessageReactions(List<Reaction> reactions) =>
|
||||||
|
Future.value();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> updateReads(String cid, List<Read> reads) => Future.value();
|
Future<void> updateReads(String cid, List<Read> reads) => Future.value();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user