Commit df891fd8 authored by LNJ's avatar LNJ 💬

chatpage: Fix avatar bug

parent e1ab4b5a
......@@ -169,6 +169,10 @@ void Database::convertDatabase()
default:
break;
}
// TODO: the next time we change the messages table, we need to do:
// * rename author to sender, edited to isEdited
// * delete author_resource, recipient_resource
}
QSqlRecord updateRecord;
......
......@@ -83,6 +83,8 @@ QHash<int, QByteArray> MessageModel::roleNames() const
QHash<int, QByteArray> roles;
roles[Timestamp] = "timestamp";
roles[Id] = "id";
roles[Sender] = "sender";
roles[Recipient] = "recipient";
roles[Body] = "body";
roles[SentByMe] = "sentByMe";
roles[MediaType] = "mediaType";
......@@ -113,6 +115,10 @@ QVariant MessageModel::data(const QModelIndex &index, int role) const
return msg.stamp();
case Id:
return msg.id();
case Sender:
return msg.from();
case Recipient:
return msg.to();
case Body:
return msg.body();
case SentByMe:
......
......@@ -48,6 +48,8 @@ public:
enum MessageRoles {
Timestamp = Qt::UserRole + 1,
Id,
Sender,
Recipient,
Body,
SentByMe,
MediaType,
......
......@@ -136,11 +136,11 @@ Kirigami.ScrollablePage {
delegate: ChatMessage {
msgId: model.id
sender: model.sender
sentByMe: model.sentByMe
messageBody: model.body
dateTime: new Date(model.timestamp)
isRead: model.isDelivered
recipientAvatarUrl: kaidan.avatarStorage.getAvatarUrl(model.author)
name: chatName
mediaType: model.mediaType
mediaGetUrl: model.mediaUrl
......
......@@ -39,11 +39,11 @@ RowLayout {
id: root
property string msgId
property string sender
property bool sentByMe: true
property string messageBody
property date dateTime
property bool isRead: false
property string recipientAvatarUrl
property int mediaType
property string mediaGetUrl
property string mediaLocation
......@@ -59,6 +59,7 @@ RowLayout {
property bool isSpoiler
property string spoilerHint
property bool isShowingSpoiler: false
property string avatarUrl: kaidan.avatarStorage.getAvatarUrl(sender)
signal messageEditRequested(string id, string body)
......@@ -74,8 +75,8 @@ RowLayout {
RoundImage {
id: avatar
visible: !sentByMe && recipientAvatarUrl !== ""
source: recipientAvatarUrl
visible: !sentByMe && avatarUrl
source: avatarUrl
fillMode: Image.PreserveAspectFit
mipmap: true
height: width
......@@ -88,7 +89,7 @@ RowLayout {
TextAvatar {
id: textAvatar
visible: !sentByMe && recipientAvatarUrl == ""
visible: !sentByMe && !avatar.visible
name: root.name
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.preferredHeight: Kirigami.Units.gridUnit * 2.2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment