fix[Chat] Jump to popup missing channel emojis
- add `emoji` to the channel list model - WIP fix hiding unavailable channels due to permissions Fixes #16623
This commit is contained in:
parent
5aefbb8446
commit
3dd94f4b72
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue