fix: CTRL+K navigation doesn't work for 1-1 chats (only for communities)

make a few "fixups" for OneToOne and Group chats so that we set the
correct `sectionId` and `sectionName`

Fixes #12264
This commit is contained in:
Lukáš Tinkl 2023-10-13 15:44:29 +02:00 committed by Lukáš Tinkl
parent 4bd3d672c6
commit 607a7acbd1
1 changed files with 7 additions and 2 deletions

View File

@ -887,6 +887,8 @@ method rebuildChatSearchModel*[T](self: Module[T]) =
var chatImage = chat.icon
var colorHash: ColorHashDto = @[]
var colorId: int = 0
var sectionId = self.view.model().getItemBySectionType(SectionType.Chat).id()
var sectionName = self.view.model().getItemBySectionType(SectionType.Chat).name()
if chat.chatType == ChatType.OneToOne:
let contactDetails = self.controller.getContactDetails(chat.id)
chatName = contactDetails.defaultDisplayName
@ -894,6 +896,9 @@ method rebuildChatSearchModel*[T](self: Module[T]) =
if not contactDetails.dto.ensVerified:
colorHash = self.controller.getColorHash(chat.id)
colorId = self.controller.getColorId(chat.id)
elif chat.chatType == ChatType.CommunityChat:
sectionId = chat.communityId
sectionName = self.view.model().getItemById(sectionId).name()
items.add(chat_search_item.initItem(
chat.id,
chatName,
@ -901,8 +906,8 @@ method rebuildChatSearchModel*[T](self: Module[T]) =
colorId,
chatImage,
colorHash.toJson(),
chat.communityId,
self.view.model().getItemById(chat.communityId).name(),
sectionId,
sectionName,
))
self.view.chatSearchModel().setItems(items)