moment/harmonyqml/components/sidePane/utils.js
miruka 8f35e60801 Capitalization, list model and room header work
- Standardized capitalization for variables and file names everywhere in
  QML and JS, get rid of mixed camelCase/snakeCase,
  use camelCase like everywhere in Qt

- ListModel items are now stored and returned as real QObjects with
  PyQt properties and signals.
  This makes dynamic property binding a lot easier and eliminates the need
  for many hacks.

- New update(), updateOrAppendWhere() methods and roles property
  for ListModel

- RoomHeader now properly updates when the room title or topic changes

- Add Backend.pdb(), to make it easier to start the debugger from QML
2019-04-20 17:43:57 -04:00

43 lines
1.2 KiB
JavaScript

.import "../chat/utils.js" as ChatJS
function getLastRoomEventText(roomId) {
var eventsModel = Backend.models.roomEvents.get(roomId)
for (var i = 0; i < eventsModel.count; i++) {
var ev = eventsModel.get(i)
if (ev.type !== "RoomMemberEvent") {
var found = true
break
}
}
if (! found) { return "" }
var name = Backend.getUserDisplayName(ev.dict.sender, false).result()
var undecryptable = ev.type === "OlmEvent" || ev.type === "MegolmEvent"
if (undecryptable || ev.type.startsWith("RoomMessage")) {
var color = ev.dict.sender === roomList.forUserId ?
"darkblue" : "purple"
return "<font color='" +
color +
"'>" +
name +
":</font> " +
(undecryptable ?
"<font color='darkred'>Undecryptable<font>" :
ev.dict.body)
} else {
return "<font color='" +
(undecryptable ? "darkred" : "#444") +
"'>" +
name +
" " +
ChatJS.getEventText(ev.type, ev.dict) +
"</font>"
}
}