moment/harmonyqml/components/SidePane/utils.js

29 lines
961 B
JavaScript
Raw Normal View History

2019-04-29 02:45:12 +10:00
.import "../Chat/utils.js" as ChatJS
2019-04-22 10:55:24 +10:00
function getLastRoomEventText(roomId, accountId) {
var eventsModel = Backend.roomEvents.get(roomId)
if (eventsModel.count < 1) { return "" }
var ev = eventsModel.get(0)
var name = Backend.getUserDisplayName(ev.dict.sender, false).result()
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-29 01:01:38 +10:00
return "<font color='" + color + "'>" +
name +
":</font> " +
(undecryptable ?
2019-04-29 01:01:38 +10:00
"<font color='darkred'>" + qsTr("Undecryptable") + "<font>" :
ev.dict.body)
} else {
2019-04-29 01:01:38 +10:00
return "<font color='" + (undecryptable ? "darkred" : "#444") + "'>" +
name +
" " +
ChatJS.getEventText(ev.type, ev.dict) +
"</font>"
}
}