fix(llc): Remove old thread reactions before saving new

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2022-03-25 15:32:13 +05:30
committed by xsahil03x
parent 981389ef8a
commit 181a2b7f63
@@ -203,6 +203,12 @@ abstract class ChatPersistenceClient {
Map<String, List<Message>> threads,
) async {
final messages = threads.values.expand((it) => it).toList();
// Removing old reactions before saving the new
final oldReactions = messages.map((it) => it.id).toList();
await deleteReactionsByMessageId(oldReactions);
// Adding new reactions and users data
final reactions = messages.expand(_expandReactions).toList();
final users = messages.map((it) => it.user).withNullifyer.toList();