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 rooms: HListModel {}
property HListModel timelines: 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 { sorters: RoleSorter {
roleName: "date" roleName: "date"
sortOrder: Qt.DescendingOrder sortOrder: Qt.DescendingOrder

View File

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