Display Chat title in SimpleMessageDelegate if sender is chat

On overviewPage I found it sufficient being empty, since the title is directly above it, anyway. But in the channel itself it looked wrong without a user name.

The name link doesn't have a href – this would only be useful for edge cases like someone sharing a "changed title" message to another chat. I did not consider that relevant enough.
This commit is contained in:
John Gibbon 2021-01-14 10:22:23 +01:00
parent 3abdbe6a58
commit 2f11b6c67c

View file

@ -24,8 +24,9 @@ import "../js/functions.js" as Functions
Item {
id: messageListItem
property var myMessage: display
property var userInformation: tdLibWrapper.getUserInformation(myMessage.sender.user_id)
property bool isOwnMessage: chatPage.myUserId === myMessage.sender.user_id
property bool senderIsUser: myMessage.sender["@type"] === "messageSenderUser"
property var userInformation: senderIsUser ? tdLibWrapper.getUserInformation(myMessage.sender.user_id) : null
property bool isOwnMessage: senderIsUser && chatPage.myUserId === myMessage.sender.user_id
height: backgroundRectangle.height + Theme.paddingMedium
Rectangle {
@ -43,7 +44,10 @@ Item {
color: Theme.highlightColor
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Theme.fontSizeExtraSmall
text: "<a style=\"text-decoration: none; font-weight: bold; color:"+Theme.primaryColor+"\" href=\"userId://" + messageListItem.userInformation.id + "\">" + (!messageListItem.isOwnMessage ? Emoji.emojify(Functions.getUserName(messageListItem.userInformation), font.pixelSize) : qsTr("You")) + "</a> " + Emoji.emojify(Functions.getMessageText(messageListItem.myMessage, false, chatPage.myUserId, false), font.pixelSize)
text: (messageListItem.senderIsUser
? "<a style=\"text-decoration: none; font-weight: bold; color:"+Theme.primaryColor+"\" href=\"userId://" + messageListItem.userInformation.id + "\">" + (!messageListItem.isOwnMessage ? Emoji.emojify(Functions.getUserName(messageListItem.userInformation), font.pixelSize) : qsTr("You")) + "</a> "
: "<a style=\"text-decoration: none; font-weight: bold; color:"+Theme.secondaryHighlightColor+"\">" + Emoji.emojify(chatPage.chatInformation.title || "") + "</a> ")
+ Emoji.emojify(Functions.getMessageText(messageListItem.myMessage, false, chatPage.myUserId, false), font.pixelSize)
textFormat: Text.RichText
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
onLinkActivated: {