timelines lastEventOf func, clickable subtitle <a>

This commit is contained in:
miruka 2019-07-04 14:43:09 -04:00
parent 63645b73a5
commit c27480d395
2 changed files with 11 additions and 10 deletions

View File

@ -41,6 +41,15 @@ QtObject {
property HListModel rooms: HListModel {}
property HListModel timelines: HListModel {
function lastEventOf(room_id) {
// Return an event item or undefined if none found
for (var i = 0; i < timelines.count; i++) {
var item = timelines.get(i) // TODO: standardize
if (item.roomId == room_id) { return item }
}
}
sorters: RoleSorter {
roleName: "date"
sortOrder: Qt.DescendingOrder

View File

@ -39,16 +39,9 @@ MouseArea {
HRichLabel {
id: subtitleLabel
visible: Boolean(text)
textFormat: Text.StyledText
text: {
for (var i = 0; i < models.timelines.count; i++) {
var item = models.timelines.get(i) // TODO: standardize
if (item.roomId == model.roomId) {
var ev = item
break
}
}
var ev = models.timelines.lastEventOf(model.roomId)
if (! ev) { return "" }
if (! Utils.eventIsMessage(ev)) {
@ -60,7 +53,6 @@ MouseArea {
ev.senderId
) + ": " + py.callSync("inlinify", [ev.content])
}
textFormat: Text.StyledText
font.pixelSize: HStyle.fontSize.small
elide: Text.ElideRight