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
This commit is contained in:
42
harmonyqml/components/sidePane/utils.js
Normal file
42
harmonyqml/components/sidePane/utils.js
Normal file
@@ -0,0 +1,42 @@
|
||||
.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>"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user