fix(@desktop/chat): no identicon/profile picture shown and wrong timestamp format in search results
Icons added for messages senders in the search result, also community and chat icons are colorized now. Fixes: #3259
This commit is contained in:
parent
f4baf7c738
commit
4916b8f552
|
@ -7,17 +7,18 @@ type SearchResultItem* = object
|
||||||
titleId: string
|
titleId: string
|
||||||
title: string
|
title: string
|
||||||
sectionName: string
|
sectionName: string
|
||||||
isLetterIdenticon: bool
|
image: string
|
||||||
badgeImage: string
|
color: string
|
||||||
badgePrimaryText: string
|
badgePrimaryText: string
|
||||||
badgeSecondaryText: string
|
badgeSecondaryText: string
|
||||||
badgeIdenticonColor: string
|
badgeImage: string
|
||||||
|
badgeIconColor: string
|
||||||
|
badgeIsLetterIdenticon: bool
|
||||||
|
|
||||||
proc initSearchResultItem*(itemId, content, time, titleId, title,
|
proc initSearchResultItem*(itemId, content, time, titleId, title,
|
||||||
sectionName: string,
|
sectionName: string, image, color, badgePrimaryText, badgeSecondaryText,
|
||||||
isLetterIdenticon: bool = false,
|
badgeImage, badgeIconColor: string = "", badgeIsLetterIdenticon: bool = false):
|
||||||
badgeImage, badgePrimaryText, badgeSecondaryText,
|
SearchResultItem =
|
||||||
badgeIdenticonColor: string = ""): SearchResultItem =
|
|
||||||
|
|
||||||
result.itemId = itemId
|
result.itemId = itemId
|
||||||
result.content = content
|
result.content = content
|
||||||
|
@ -25,11 +26,13 @@ proc initSearchResultItem*(itemId, content, time, titleId, title,
|
||||||
result.titleId = titleId
|
result.titleId = titleId
|
||||||
result.title = title
|
result.title = title
|
||||||
result.sectionName = sectionName
|
result.sectionName = sectionName
|
||||||
result.isLetterIdenticon = isLetterIdenticon
|
result.image = image
|
||||||
result.badgeImage = badgeImage
|
result.color = color
|
||||||
result.badgePrimaryText = badgePrimaryText
|
result.badgePrimaryText = badgePrimaryText
|
||||||
result.badgeSecondaryText = badgeSecondaryText
|
result.badgeSecondaryText = badgeSecondaryText
|
||||||
result.badgeIdenticonColor = badgeIdenticonColor
|
result.badgeImage = badgeImage
|
||||||
|
result.badgeIconColor = badgeIconColor
|
||||||
|
result.badgeIsLetterIdenticon = badgeIsLetterIdenticon
|
||||||
|
|
||||||
proc `$`*(self: SearchResultItem): string =
|
proc `$`*(self: SearchResultItem): string =
|
||||||
result = "MessageSearchResultItem("
|
result = "MessageSearchResultItem("
|
||||||
|
@ -39,11 +42,13 @@ proc `$`*(self: SearchResultItem): string =
|
||||||
result &= fmt"titleId:{self.titleId}, "
|
result &= fmt"titleId:{self.titleId}, "
|
||||||
result &= fmt"title:{self.title}"
|
result &= fmt"title:{self.title}"
|
||||||
result &= fmt"sectionName:{self.sectionName}"
|
result &= fmt"sectionName:{self.sectionName}"
|
||||||
result &= fmt"isLetterIdenticon:{self.isLetterIdenticon}"
|
result &= fmt"image:{self.image}"
|
||||||
result &= fmt"badgeImage:{self.badgeImage}"
|
result &= fmt"color:{self.color}"
|
||||||
result &= fmt"badgePrimaryText:{self.badgePrimaryText}"
|
result &= fmt"badgePrimaryText:{self.badgePrimaryText}"
|
||||||
result &= fmt"badgeSecondaryText:{self.badgeSecondaryText}"
|
result &= fmt"badgeSecondaryText:{self.badgeSecondaryText}"
|
||||||
result &= fmt"badgeIdenticonColor:{self.badgeIdenticonColor}"
|
result &= fmt"badgeImage:{self.badgeImage}"
|
||||||
|
result &= fmt"badgeIconColor:{self.badgeIconColor}"
|
||||||
|
result &= fmt"badgeIsLetterIdenticon:{self.badgeIsLetterIdenticon}"
|
||||||
result &= ")"
|
result &= ")"
|
||||||
|
|
||||||
method getItemId*(self: SearchResultItem): string {.base.} =
|
method getItemId*(self: SearchResultItem): string {.base.} =
|
||||||
|
@ -64,11 +69,11 @@ method getTitle*(self: SearchResultItem): string {.base.} =
|
||||||
method getSectionName*(self: SearchResultItem): string {.base.} =
|
method getSectionName*(self: SearchResultItem): string {.base.} =
|
||||||
return self.sectionName
|
return self.sectionName
|
||||||
|
|
||||||
method getIsLetterIdentIcon*(self: SearchResultItem): bool {.base.} =
|
method getImage*(self: SearchResultItem): string {.base.} =
|
||||||
return self.isLetterIdenticon
|
return self.image
|
||||||
|
|
||||||
method getBadgeImage*(self: SearchResultItem): string {.base.} =
|
method getColor*(self: SearchResultItem): string {.base.} =
|
||||||
return self.badgeImage
|
return self.color
|
||||||
|
|
||||||
method getBadgePrimaryText*(self: SearchResultItem): string {.base.} =
|
method getBadgePrimaryText*(self: SearchResultItem): string {.base.} =
|
||||||
return self.badgePrimaryText
|
return self.badgePrimaryText
|
||||||
|
@ -76,5 +81,11 @@ method getBadgePrimaryText*(self: SearchResultItem): string {.base.} =
|
||||||
method getBadgeSecondaryText*(self: SearchResultItem): string {.base.} =
|
method getBadgeSecondaryText*(self: SearchResultItem): string {.base.} =
|
||||||
return self.badgeSecondaryText
|
return self.badgeSecondaryText
|
||||||
|
|
||||||
method getBadgeIdenticonColor*(self: SearchResultItem): string {.base.} =
|
method getBadgeImage*(self: SearchResultItem): string {.base.} =
|
||||||
return self.badgeIdenticonColor
|
return self.badgeImage
|
||||||
|
|
||||||
|
method getBadgeIconColor*(self: SearchResultItem): string {.base.} =
|
||||||
|
return self.badgeIconColor
|
||||||
|
|
||||||
|
method getBadgeIsLetterIdenticon*(self: SearchResultItem): bool {.base.} =
|
||||||
|
return self.badgeIsLetterIdenticon
|
|
@ -10,11 +10,13 @@ type
|
||||||
TitleId
|
TitleId
|
||||||
Title
|
Title
|
||||||
SectionName
|
SectionName
|
||||||
IsLetterIdenticon
|
Image
|
||||||
BadgeImage
|
Color
|
||||||
BadgePrimaryText
|
BadgePrimaryText
|
||||||
BadgeSecondaryText
|
BadgeSecondaryText
|
||||||
BadgeIdenticonColor
|
BadgeImage
|
||||||
|
BadgeIconColor
|
||||||
|
BadgeIsLetterIdenticon
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type
|
type
|
||||||
|
@ -55,11 +57,13 @@ QtObject:
|
||||||
MessageSearchResultModelRole.TitleId.int:"titleId",
|
MessageSearchResultModelRole.TitleId.int:"titleId",
|
||||||
MessageSearchResultModelRole.Title.int:"title",
|
MessageSearchResultModelRole.Title.int:"title",
|
||||||
MessageSearchResultModelRole.SectionName.int:"sectionName",
|
MessageSearchResultModelRole.SectionName.int:"sectionName",
|
||||||
MessageSearchResultModelRole.IsLetterIdenticon.int:"isLetterIdenticon",
|
MessageSearchResultModelRole.Image.int:"image",
|
||||||
MessageSearchResultModelRole.BadgeImage.int:"badgeImage",
|
MessageSearchResultModelRole.Color.int:"color",
|
||||||
MessageSearchResultModelRole.BadgePrimaryText.int:"badgePrimaryText",
|
MessageSearchResultModelRole.BadgePrimaryText.int:"badgePrimaryText",
|
||||||
MessageSearchResultModelRole.BadgeSecondaryText.int:"badgeSecondaryText",
|
MessageSearchResultModelRole.BadgeSecondaryText.int:"badgeSecondaryText",
|
||||||
MessageSearchResultModelRole.BadgeIdenticonColor.int:"badgeIdenticonColor"
|
MessageSearchResultModelRole.BadgeImage.int:"badgeImage",
|
||||||
|
MessageSearchResultModelRole.BadgeIconColor.int:"badgeIconColor",
|
||||||
|
MessageSearchResultModelRole.BadgeIsLetterIdenticon.int:"badgeIsLetterIdenticon"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
method data(self: MessageSearchResultModel, index: QModelIndex, role: int): QVariant =
|
method data(self: MessageSearchResultModel, index: QModelIndex, role: int): QVariant =
|
||||||
|
@ -85,16 +89,20 @@ QtObject:
|
||||||
result = newQVariant(item.getTitle)
|
result = newQVariant(item.getTitle)
|
||||||
of MessageSearchResultModelRole.SectionName:
|
of MessageSearchResultModelRole.SectionName:
|
||||||
result = newQVariant(item.getSectionName)
|
result = newQVariant(item.getSectionName)
|
||||||
of MessageSearchResultModelRole.IsLetterIdenticon:
|
of MessageSearchResultModelRole.Image:
|
||||||
result = newQVariant(item.getIsLetterIdentIcon)
|
result = newQVariant(item.getImage)
|
||||||
of MessageSearchResultModelRole.BadgeImage:
|
of MessageSearchResultModelRole.Color:
|
||||||
result = newQVariant(item.getBadgeImage)
|
result = newQVariant(item.getColor)
|
||||||
of MessageSearchResultModelRole.BadgePrimaryText:
|
of MessageSearchResultModelRole.BadgePrimaryText:
|
||||||
result = newQVariant(item.getBadgePrimaryText)
|
result = newQVariant(item.getBadgePrimaryText)
|
||||||
of MessageSearchResultModelRole.BadgeSecondaryText:
|
of MessageSearchResultModelRole.BadgeSecondaryText:
|
||||||
result = newQVariant(item.getBadgeSecondaryText)
|
result = newQVariant(item.getBadgeSecondaryText)
|
||||||
of MessageSearchResultModelRole.BadgeIdenticonColor:
|
of MessageSearchResultModelRole.BadgeImage:
|
||||||
result = newQVariant(item.getBadgeIdenticonColor)
|
result = newQVariant(item.getBadgeImage)
|
||||||
|
of MessageSearchResultModelRole.BadgeIconColor:
|
||||||
|
result = newQVariant(item.getBadgeIconColor)
|
||||||
|
of MessageSearchResultModelRole.BadgeIsLetterIdenticon:
|
||||||
|
result = newQVariant(item.getBadgeIsLetterIdentIcon)
|
||||||
|
|
||||||
proc add*(self: MessageSearchResultModel, item: SearchResultItem) =
|
proc add*(self: MessageSearchResultModel, item: SearchResultItem) =
|
||||||
self.beginInsertRows(newQModelIndex(), self.resultList.len, self.resultList.len)
|
self.beginInsertRows(newQModelIndex(), self.resultList.len, self.resultList.len)
|
||||||
|
|
|
@ -164,8 +164,9 @@ QtObject:
|
||||||
if(self.meassgeSearchLocation.len == 0 and
|
if(self.meassgeSearchLocation.len == 0 and
|
||||||
co.name.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
co.name.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
||||||
let item = initSearchResultItem(co.id, "", "", co.id, co.name,
|
let item = initSearchResultItem(co.id, "", "", co.id, co.name,
|
||||||
sr_constants.SEARCH_RESULT_COMMUNITIES_SECTION_NAME, false,
|
sr_constants.SEARCH_RESULT_COMMUNITIES_SECTION_NAME,
|
||||||
co.communityImage.thumbnail, "", "", co.communityColor)
|
co.communityImage.thumbnail, co.communityColor, "", "",
|
||||||
|
co.communityImage.thumbnail, co.communityColor)
|
||||||
|
|
||||||
self.resultItems.add(co.id, ResultItemInfo(communityId: co.id))
|
self.resultItems.add(co.id, ResultItemInfo(communityId: co.id))
|
||||||
items.add(item)
|
items.add(item)
|
||||||
|
@ -182,8 +183,9 @@ QtObject:
|
||||||
|
|
||||||
if(chatNameRaw.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
if(chatNameRaw.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
||||||
let item = initSearchResultItem(c.id, "", "", c.id, chatName,
|
let item = initSearchResultItem(c.id, "", "", c.id, chatName,
|
||||||
sr_constants.SEARCH_RESULT_CHANNELS_SECTION_NAME,
|
sr_constants.SEARCH_RESULT_CHANNELS_SECTION_NAME,
|
||||||
c.identicon.len > 0, c.identicon, "", "", c.color)
|
c.identicon, c.color, "", "", c.identicon, c.color,
|
||||||
|
c.identicon.len > 0)
|
||||||
|
|
||||||
self.resultItems.add(c.id, ResultItemInfo(communityId: co.id,
|
self.resultItems.add(c.id, ResultItemInfo(communityId: co.id,
|
||||||
channelId: c.id))
|
channelId: c.id))
|
||||||
|
@ -200,9 +202,9 @@ QtObject:
|
||||||
|
|
||||||
if(chatNameRaw.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
if(chatNameRaw.toLower.startsWith(self.meassgeSearchTerm.toLower)):
|
||||||
let item = initSearchResultItem(c.id, "", "", c.id, chatName,
|
let item = initSearchResultItem(c.id, "", "", c.id, chatName,
|
||||||
sr_constants.SEARCH_RESULT_CHATS_SECTION_NAME,
|
sr_constants.SEARCH_RESULT_CHATS_SECTION_NAME, c.identicon, c.color,
|
||||||
c.identicon.len > 0, c.identicon, "", "", c.color)
|
"", "", c.identicon, c.color, c.identicon.len > 0)
|
||||||
|
|
||||||
self.resultItems.add(c.id, ResultItemInfo(communityId: "",
|
self.resultItems.add(c.id, ResultItemInfo(communityId: "",
|
||||||
channelId: c.id))
|
channelId: c.id))
|
||||||
items.add(item)
|
items.add(item)
|
||||||
|
@ -217,6 +219,7 @@ QtObject:
|
||||||
|
|
||||||
var found = false
|
var found = false
|
||||||
var chat = self.channelView.chats.getChannelById(m.chatId, found)
|
var chat = self.channelView.chats.getChannelById(m.chatId, found)
|
||||||
|
let image = if(m.image.len > 0): m.image else: m.identicon
|
||||||
if (found):
|
if (found):
|
||||||
var channel = self.status.chat.chatName(chat)
|
var channel = self.status.chat.chatName(chat)
|
||||||
if (channel.endsWith(".stateofus.eth")):
|
if (channel.endsWith(".stateofus.eth")):
|
||||||
|
@ -227,8 +230,8 @@ QtObject:
|
||||||
alias = "You"
|
alias = "You"
|
||||||
|
|
||||||
let item = initSearchResultItem(m.id, m.text, m.timestamp, m.fromAuthor,
|
let item = initSearchResultItem(m.id, m.text, m.timestamp, m.fromAuthor,
|
||||||
alias, sr_constants.SEARCH_RESULT_MESSAGES_SECTION_NAME,
|
alias, sr_constants.SEARCH_RESULT_MESSAGES_SECTION_NAME, image, "",
|
||||||
chat.identicon.len == 0, chat.identicon, channel, "", chat.color)
|
channel, "", chat.identicon, chat.color, chat.identicon.len == 0)
|
||||||
|
|
||||||
self.resultItems.add(m.id, ResultItemInfo(communityId: "",
|
self.resultItems.add(m.id, ResultItemInfo(communityId: "",
|
||||||
channelId: chat.id, messageId: m.id))
|
channelId: chat.id, messageId: m.id))
|
||||||
|
@ -249,10 +252,9 @@ QtObject:
|
||||||
alias = "You"
|
alias = "You"
|
||||||
|
|
||||||
let item = initSearchResultItem(m.id, m.text, m.timestamp, m.fromAuthor,
|
let item = initSearchResultItem(m.id, m.text, m.timestamp, m.fromAuthor,
|
||||||
m.alias, sr_constants.SEARCH_RESULT_MESSAGES_SECTION_NAME,
|
m.alias, sr_constants.SEARCH_RESULT_MESSAGES_SECTION_NAME, image, "",
|
||||||
community.communityImage.thumbnail.len == 0,
|
community.name, channel, community.communityImage.thumbnail,
|
||||||
community.communityImage.thumbnail, community.name, channel,
|
community.communityColor, community.communityImage.thumbnail.len == 0)
|
||||||
community.communityColor)
|
|
||||||
|
|
||||||
self.resultItems.add(m.id, ResultItemInfo(communityId: community.id,
|
self.resultItems.add(m.id, ResultItemInfo(communityId: community.id,
|
||||||
channelId: chat.id, messageId: m.id))
|
channelId: chat.id, messageId: m.id))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 450e863d44cac7c4b1e3f92c1c011f4f69e0cc6d
|
Subproject commit b45aba4be88fbdd4adf901b90dbe07c93c98aaea
|
|
@ -70,6 +70,11 @@ StatusAppThreePanelLayout {
|
||||||
|
|
||||||
searchOptionsPopupMenu: searchPopupMenu
|
searchOptionsPopupMenu: searchPopupMenu
|
||||||
searchResults: chatsModel.messageSearchViewController.resultModel
|
searchResults: chatsModel.messageSearchViewController.resultModel
|
||||||
|
|
||||||
|
formatTimestampFn: function (ts) {
|
||||||
|
return new Date(parseInt(ts, 10)).toLocaleString(Qt.locale(globalSettings.locale))
|
||||||
|
}
|
||||||
|
|
||||||
onSearchTextChanged: {
|
onSearchTextChanged: {
|
||||||
searchMessages(searchPopup.searchText);
|
searchMessages(searchPopup.searchText);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue