Rooms and threads fixes

- Fix roomList height again, now based on model.count().
  All delegates are assumed to be the same height

- Properly update room list when a room is joined or left

- Catch exceptions happening in threads (futures), which previously
  passed silently

- Show "Empty room?" as "<i>Empty Room</i>" + gray [?] avatar
This commit is contained in:
miruka
2019-04-13 08:59:10 -04:00
parent d8c6ffefe0
commit 13fca98838
8 changed files with 58 additions and 36 deletions

View File

@@ -6,7 +6,7 @@ import "../base" as Base
MouseArea {
id: "root"
width: roomList.width
height: Math.max(roomLabel.height + subtitleLabel.height, avatar.height)
height: roomList.childrenHeight
onClicked: pageStack.show_room(
roomList.user_id,
@@ -18,14 +18,15 @@ MouseArea {
id: row
spacing: 1
Base.Avatar { id: avatar; name: display_name; dimmension: 36 }
Base.Avatar { id: avatar; name: display_name; dimmension: root.height }
ColumnLayout {
spacing: 0
Base.HLabel {
id: roomLabel
text: display_name
text: display_name ? display_name : "<i>Empty room</i>"
textFormat: Text.StyledText
elide: Text.ElideRight
maximumLineCount: 1
Layout.maximumWidth: row.width - row.spacing - avatar.width
@@ -37,11 +38,12 @@ MouseArea {
rightPadding: leftPadding
}
Base.HLabel {
function get_text() {
var msgs = Backend.models.messages.get(room_id)
if (! msgs || msgs.count < 1) { return "" }
property var msgModel: Backend.models.messages.get(room_id)
var msg = msgs.get(-1)
function get_text() {
if (msgModel.count < 1) { return "" }
var msg = msgModel.get(-1)
var color_ = (msg.sender_id === roomList.user_id ?
"darkblue" : "purple")
var client = Backend.clientManager.clients[RoomList.for_user_id]
@@ -54,7 +56,7 @@ MouseArea {
id: subtitleLabel
visible: text !== ""
text: Backend.models.messages.get(room_id).reloadThis, get_text()
text: msgModel.reloadThis, get_text()
textFormat: Text.StyledText
font.pixelSize: smallSize

View File

@@ -6,17 +6,12 @@ import "../base" as Base
ListView {
property var for_user_id: null
property int childrenHeight: 36
property int contentHeight: 0
onCountChanged: {
var children = roomList.contentItem.children
var childrenHeight = 0
for (var i = 0; i < children.length; i++) {
childrenHeight += children[i].height
}
contentHeight = childrenHeight + spacing * (children.length - 1)
contentHeight = childrenHeight * model.count +
spacing * (model.count - 1)
}
id: "roomList"