From 33a866463da2f590766487d9d1c14dd4c4018a81 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Thu, 17 Nov 2022 09:58:52 +0000 Subject: [PATCH] core: fix sql that was doubling a group in the list of chats when member joined the group twice (#1378) --- src/Simplex/Chat/Store.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Chat/Store.hs b/src/Simplex/Chat/Store.hs index 121f08cf4..69b8d051f 100644 --- a/src/Simplex/Chat/Store.hs +++ b/src/Simplex/Chat/Store.hs @@ -3230,7 +3230,7 @@ getDirectChatPreviews_ db User {userId} = do WHERE item_status = ? AND item_deleted != 1 GROUP BY contact_id ) ChatStats ON ChatStats.contact_id = ct.contact_id - LEFT JOIN chat_items ri ON i.quoted_shared_msg_id = ri.shared_msg_id + LEFT JOIN chat_items ri ON ri.shared_msg_id = i.quoted_shared_msg_id AND ri.contact_id = i.contact_id WHERE ct.user_id = ? AND ((c.conn_level = 0 AND c.via_group_link = 0) OR ct.contact_used = 1) AND c.connection_id = ( @@ -3307,7 +3307,7 @@ getGroupChatPreviews_ db User {userId, userContactId} = do ) ChatStats ON ChatStats.group_id = g.group_id LEFT JOIN group_members m ON m.group_member_id = i.group_member_id LEFT JOIN contact_profiles p ON p.contact_profile_id = COALESCE(m.member_profile_id, m.contact_profile_id) - LEFT JOIN chat_items ri ON i.quoted_shared_msg_id = ri.shared_msg_id + LEFT JOIN chat_items ri ON ri.shared_msg_id = i.quoted_shared_msg_id AND ri.group_id = i.group_id LEFT JOIN group_members rm ON rm.group_member_id = ri.group_member_id LEFT JOIN contact_profiles rp ON rp.contact_profile_id = COALESCE(rm.member_profile_id, rm.contact_profile_id) WHERE g.user_id = ? AND mu.contact_id = ?