2
0
mirror of https://github.com/status-im/status-desktop.git synced 2025-01-10 22:36:24 +00:00

fix(search): order personal messages by lastMessageTimestamp

This commit is contained in:
Jonathan Rainville 2024-12-19 11:13:39 -05:00
parent cdc2ab1a20
commit af6b503656
4 changed files with 25 additions and 7 deletions

@ -11,6 +11,7 @@ type
colorId: int
colorHash: color_hash_model.Model
position: int
lastMessageTimestamp: int
proc initSubItem*(
value,
@ -30,6 +31,7 @@ proc initSubItem*(
result.isUserIcon = isUserIcon
result.isImage = isImage
result.position = position
result.lastMessageTimestamp = lastMessageTimestamp
result.colorId = colorId
result.colorHash = color_hash_model.newModel()
result.colorHash.setItems(map(colorHash, x => color_hash_item.initItem(x.len, x.colorIdx)))
@ -55,6 +57,7 @@ proc toJsonNode*(self: SubItem): JsonNode =
"value": self.value,
"text": self.text,
"position": self.position,
"lastMessageTimestamp": self.lastMessageTimestamp,
"imageSource": self.image,
"iconName": self.icon,
"iconColor": self.iconColor,
@ -67,6 +70,9 @@ proc toJsonNode*(self: SubItem): JsonNode =
proc position*(self: SubItem): int =
return self.position
proc lastMessageTimestamp*(self: SubItem): int =
return self.lastMessageTimestamp
proc isUserIcon*(self: SubItem): bool =
return self.isUserIcon

@ -12,6 +12,7 @@ type
IsUserIcon
IsImage
Position
LastMessageTimestamp
ColorId
ColorHash
@ -61,6 +62,7 @@ QtObject:
SubModelRole.IsUserIcon.int:"isUserIcon",
SubModelRole.IsImage.int:"isImage",
SubModelRole.Position.int:"position",
SubModelRole.LastMessageTimestamp.int:"lastMessageTimestamp",
SubModelRole.ColorId.int:"colorId",
SubModelRole.ColorHash.int:"colorHash"
}.toTable
@ -92,6 +94,8 @@ QtObject:
result = newQVariant(item.isImage)
of SubModelRole.Position:
result = newQVariant(item.position)
of SubModelRole.LastMessageTimestamp:
result = newQVariant(item.lastMessageTimestamp)
of SubModelRole.ColorId:
result = newQVariant(item.colorId)
of SubModelRole.ColorHash:

@ -99,12 +99,13 @@ proc getChatSubItems(self: Module, chats: seq[ChatDto], categories: seq[Category
let subItem = location_menu_sub_item.initSubItem(
chatDto.id,
chatName,
if (chatImage != ""): chatImage else: chatDto.emoji,
"",
image = if (chatImage != ""): chatImage else: chatDto.emoji,
icon = "",
chatDto.color,
isOneToOneChat,
isImage = chatImage != "",
chatDto.position,
chatDto.timestamp.int,
colorId,
colorHash,
)
@ -120,11 +121,12 @@ proc getChatSubItems(self: Module, chats: seq[ChatDto], categories: seq[Category
chat.id,
chat.name,
chat.emoji,
"",
icon = "",
chat.color,
isUserIcon = false,
isImage = false,
chatPosition,
chat.timestamp.int,
))
highestPosition += categoryChats[categoryPosition].len

@ -123,10 +123,16 @@ StatusMenu {
menu: subMenuDelegate
model: SortFilterProxyModel {
sourceModel: subMenuDelegate.subItemsModel
sorters: RoleSorter {
roleName: "position"
sortOrder: Qt.AscendingOrder
}
sorters: [
RoleSorter {
roleName: "position"
sortOrder: Qt.AscendingOrder
},
RoleSorter {
roleName: "lastMessageTimestamp"
sortOrder: Qt.DescendingOrder
}
]
}
delegate: StatusSearchPopupMenuItem {