core: fix duplicate banner when connecting to member contact (#6118)

This commit is contained in:
spaced4ndy
2025-07-28 09:37:14 +00:00
committed by GitHub
parent d65ac99ba2
commit 5de9bf7f2b
3 changed files with 18 additions and 2 deletions
+9
View File
@@ -43,6 +43,7 @@ module Simplex.Chat.Store.Messages
createNewChatItemNoMsg,
createNewChatItem_,
getChatPreviews,
checkContactHasItems,
getDirectChat,
getGroupChat,
getGroupChatScopeInfoForItem,
@@ -1130,6 +1131,14 @@ getContactConnectionChatPreviews_ db User {userId} pagination clq = case clq of
aChat = AChat SCTContactConnection $ Chat (ContactConnection conn) [] emptyChatStats
in ACPD SCTContactConnection $ ContactConnectionPD updatedAt aChat
checkContactHasItems :: DB.Connection -> User -> Contact -> IO Bool
checkContactHasItems db User {userId} Contact {contactId} =
fromOnly . head
<$> DB.query
db
"SELECT EXISTS (SELECT 1 FROM chat_items WHERE user_id = ? AND contact_id = ?)"
(userId, contactId)
getDirectChat :: DB.Connection -> VersionRangeChat -> User -> Int64 -> ChatPagination -> Maybe String -> ExceptT StoreError IO (Chat 'CTDirect, Maybe NavigationInfo)
getDirectChat db vr user contactId pagination search_ = do
let search = fromMaybe "" search_
@@ -5830,6 +5830,12 @@ Query: SELECT COUNT(1), COALESCE(SUM(user_mention), 0) FROM chat_items WHERE use
Plan:
SEARCH chat_items USING COVERING INDEX idx_chat_items_group_scope_stats_all (user_id=? AND group_id=? AND group_scope_tag=? AND group_scope_group_member_id=? AND item_status=?)
Query: SELECT EXISTS (SELECT 1 FROM chat_items WHERE user_id = ? AND contact_id = ?)
Plan:
SCAN CONSTANT ROW
SCALAR SUBQUERY 1
SEARCH chat_items USING COVERING INDEX idx_chat_items_contacts_created_at (user_id=? AND contact_id=?)
Query: SELECT accepted_at FROM operator_usage_conditions WHERE server_operator_id = ? AND conditions_commit = ?
Plan:
SEARCH operator_usage_conditions USING INDEX idx_operator_usage_conditions_conditions_commit (conditions_commit=? AND server_operator_id=?)