2019-04-29 02:45:12 +10:00
|
|
|
.import "../Chat/utils.js" as ChatJS
|
2019-04-15 04:09:54 +10:00
|
|
|
|
|
|
|
|
2019-04-22 10:55:24 +10:00
|
|
|
function getLastRoomEventText(roomId, accountId) {
|
2019-05-03 04:31:47 +10:00
|
|
|
var eventsModel = Backend.roomEvents.get(roomId)
|
2019-05-03 04:20:21 +10:00
|
|
|
if (eventsModel.count < 1) { return "" }
|
|
|
|
var ev = eventsModel.get(0)
|
2019-04-15 04:09:54 +10:00
|
|
|
|
2019-04-19 16:07:01 +10:00
|
|
|
var name = Backend.getUserDisplayName(ev.dict.sender, false).result()
|
2019-04-15 04:09:54 +10:00
|
|
|
var undecryptable = ev.type === "OlmEvent" || ev.type === "MegolmEvent"
|
|
|
|
|
|
|
|
if (undecryptable || ev.type.startsWith("RoomMessage")) {
|
2019-04-29 01:01:38 +10:00
|
|
|
var color = Qt.hsla(Backend.hueFromString(name), 0.32, 0.3, 1)
|
2019-04-15 04:09:54 +10:00
|
|
|
|
2019-04-29 01:01:38 +10:00
|
|
|
return "<font color='" + color + "'>" +
|
2019-04-15 04:09:54 +10:00
|
|
|
name +
|
|
|
|
":</font> " +
|
|
|
|
(undecryptable ?
|
2019-04-29 01:01:38 +10:00
|
|
|
"<font color='darkred'>" + qsTr("Undecryptable") + "<font>" :
|
2019-04-15 04:09:54 +10:00
|
|
|
ev.dict.body)
|
|
|
|
} else {
|
2019-04-29 01:01:38 +10:00
|
|
|
return "<font color='" + (undecryptable ? "darkred" : "#444") + "'>" +
|
2019-04-15 04:09:54 +10:00
|
|
|
name +
|
|
|
|
" " +
|
2019-04-21 07:36:21 +10:00
|
|
|
ChatJS.getEventText(ev.type, ev.dict) +
|
2019-04-15 04:09:54 +10:00
|
|
|
"</font>"
|
|
|
|
}
|
|
|
|
}
|