From f5d747cbc428e0ec7bcd72ed9d2fa0b4c294d531 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 18 Jul 2019 02:36:08 -0400 Subject: [PATCH] Fix wrong avatar for unamed rooms --- TODO.md | 1 - src/qml/Base/HRoomAvatar.qml | 5 ++++- src/qml/Chat/RoomHeader.qml | 1 + src/qml/EventHandlers/rooms.js | 1 - src/qml/SidePane/RoomDelegate.qml | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 132e4169..00219330 100644 --- a/TODO.md +++ b/TODO.md @@ -20,7 +20,6 @@ - Room Sidepane - Bug fixes - - Wrong avatar for group rooms - Past events loading (limit 100) freezes the GUI - need to move upsert func to a WorkerScript - `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function` diff --git a/src/qml/Base/HRoomAvatar.qml b/src/qml/Base/HRoomAvatar.qml index 6968c84c..67539d79 100644 --- a/src/qml/Base/HRoomAvatar.qml +++ b/src/qml/Base/HRoomAvatar.qml @@ -4,10 +4,13 @@ import QtQuick 2.12 HAvatar { + property string userId: "" property string roomId: "" + readonly property var roomInfo: + rooms.getWhere({"userId": userId, "roomId": roomId}, 1)[0] + // roomInfo ? → Avoid error messages when a room is forgotten - readonly property var roomInfo: rooms.getWhere({"roomId": roomId}, 1)[0] readonly property var dname: roomInfo ? roomInfo.displayName : "" name: diff --git a/src/qml/Chat/RoomHeader.qml b/src/qml/Chat/RoomHeader.qml index 7861c850..331b7e83 100644 --- a/src/qml/Chat/RoomHeader.qml +++ b/src/qml/Chat/RoomHeader.qml @@ -29,6 +29,7 @@ HRectangle { HRoomAvatar { id: avatar + userId: chatPage.userId roomId: chatPage.roomId Layout.alignment: Qt.AlignTop } diff --git a/src/qml/EventHandlers/rooms.js b/src/qml/EventHandlers/rooms.js index 210f6bab..c32e12c9 100644 --- a/src/qml/EventHandlers/rooms.js +++ b/src/qml/EventHandlers/rooms.js @@ -77,7 +77,6 @@ function onRoomUpdated( } else { rooms.set(replace, item) } - } diff --git a/src/qml/SidePane/RoomDelegate.qml b/src/qml/SidePane/RoomDelegate.qml index 00a65aa4..370bdbf4 100644 --- a/src/qml/SidePane/RoomDelegate.qml +++ b/src/qml/SidePane/RoomDelegate.qml @@ -29,6 +29,7 @@ HInteractiveRectangle { HRoomAvatar { id: roomAvatar + userId: model.userId roomId: model.roomId }