diff --git a/src/app/modules/main/chat_search_item.nim b/src/app/modules/main/chat_search_item.nim index dda06f222d..a1eeb74e69 100644 --- a/src/app/modules/main/chat_search_item.nim +++ b/src/app/modules/main/chat_search_item.nim @@ -8,8 +8,9 @@ type sectionId: string sectionName: string colorHash: string + emoji: string -proc initItem*(chatId, name, color: string, colorId: int, icon, colorHash, sectionId, sectionName: string): Item = +proc initItem*(chatId, name, color: string, colorId: int, icon, colorHash, sectionId, sectionName, emoji: string): Item = result = Item() result.chatId = chatId result.name = name @@ -19,6 +20,7 @@ proc initItem*(chatId, name, color: string, colorId: int, icon, colorHash, secti result.colorHash = colorHash result.sectionId = sectionId result.sectionName = sectionName + result.emoji = emoji proc chatId*(self: Item): string = self.chatId @@ -43,3 +45,6 @@ proc sectionId*(self: Item): string = proc sectionName*(self: Item): string = self.sectionName + +proc emoji*(self: Item): string = + self.emoji diff --git a/src/app/modules/main/chat_search_model.nim b/src/app/modules/main/chat_search_model.nim index 61b01a27c1..40fcf4d502 100644 --- a/src/app/modules/main/chat_search_model.nim +++ b/src/app/modules/main/chat_search_model.nim @@ -11,6 +11,7 @@ type ColorHash SectionId SectionName + Emoji QtObject: type Model* = ref object of QAbstractListModel @@ -45,6 +46,7 @@ QtObject: ModelRole.ColorHash.int:"colorHash", ModelRole.SectionId.int:"sectionId", ModelRole.SectionName.int:"sectionName", + ModelRole.Emoji.int:"emoji", }.toTable method data(self: Model, index: QModelIndex, role: int): QVariant = @@ -72,3 +74,5 @@ QtObject: result = newQVariant(item.sectionId) of ModelRole.SectionName: result = newQVariant(item.sectionName) + of ModelRole.Emoji: + result = newQVariant(item.emoji) diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 62258553ec..179d340ae8 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -989,6 +989,27 @@ method getCommunitySectionModule*[T](self: Module[T], communityId: string): QVar method rebuildChatSearchModel*[T](self: Module[T]) = var items: seq[chat_search_item.Item] = @[] for chat in self.controller.getAllChats(): + let communityId = chat.communityId + + # try to skip hidden chats + if chat.chatType == ChatType.CommunityChat and communityId != "": + let communityDto = self.controller.getCommunityById(communityId) + var chatId = chat.id + if not communityDto.hasCommunityChat(chatId): + # try with shortened chatId + warn "!!! main-module, unexisting communityId for chatId", communityId, chatId + chatId.removePrefix(communityId) + if not chatId.startsWith("0x"): + chatId = "0x" % chatId + + if not communityDto.hasCommunityChat(chatId): + warn "!!! main-module, unexisting communityId for shortened chatId", communityId, chatId + #continue + else: + let communityChat = communityDto.getCommunityChat(chatId) + if communityChat.isHiddenChat: + continue + var chatName = chat.name var chatImage = chat.icon var colorHash: ColorHashDto = @[] @@ -1003,7 +1024,7 @@ method rebuildChatSearchModel*[T](self: Module[T]) = colorHash = self.controller.getColorHash(chat.id) colorId = self.controller.getColorId(chat.id) elif chat.chatType == ChatType.CommunityChat: - sectionId = chat.communityId + sectionId = communityId sectionName = self.view.model().getItemById(sectionId).name() items.add(chat_search_item.initItem( chat.id, @@ -1014,6 +1035,7 @@ method rebuildChatSearchModel*[T](self: Module[T]) = colorHash.toJson(), sectionId, sectionName, + chat.emoji, )) self.view.chatSearchModel().setItems(items) diff --git a/src/app_service/service/contacts/dto/contacts.nim b/src/app_service/service/contacts/dto/contacts.nim index 135eb7bd76..6a41a02153 100644 --- a/src/app_service/service/contacts/dto/contacts.nim +++ b/src/app_service/service/contacts/dto/contacts.nim @@ -77,12 +77,12 @@ proc toImages(jsonObj: JsonNode): Images = proc toContactRequestState*(value: int): ContactRequestState = result = ContactRequestState.None - if value >= ord(low(ContactRequestState)) or value <= ord(high(ContactRequestState)): + if value >= ord(low(ContactRequestState)) and value <= ord(high(ContactRequestState)): result = ContactRequestState(value) proc toTrustStatus*(value: int): TrustStatus = result = TrustStatus.Unknown - if value >= ord(low(TrustStatus)) or value <= ord(high(TrustStatus)): + if value >= ord(low(TrustStatus)) and value <= ord(high(TrustStatus)): result = TrustStatus(value) proc toContactsDto*(jsonObj: JsonNode): ContactsDto = diff --git a/ui/imports/shared/status/StatusSearchListPopup.qml b/ui/imports/shared/status/StatusSearchListPopup.qml index 8125c1eece..138bd4e5fe 100644 --- a/ui/imports/shared/status/StatusSearchListPopup.qml +++ b/ui/imports/shared/status/StatusSearchListPopup.qml @@ -109,6 +109,10 @@ Popup { roleName: "name" searchPhrase: searchBox.text } + enabled: !!searchBox.text + } + sorters: StringSorter { + roleName: "name" } } @@ -132,6 +136,7 @@ Popup { asset.height: 30 asset.color: model ? model.color ? model.color : Utils.colorForColorId(model.colorId) : "" asset.name: model ? model.icon : "" + asset.emoji: model ? model.emoji : "" asset.charactersLen: 2 asset.letterSize: asset._twoLettersSize ringSettings.ringSpecModel: model ? model.colorHash : undefined