fix: fix mention showing as pubkey and show styling

This commit is contained in:
Jonathan Rainville 2021-03-23 14:15:26 -04:00 committed by Iuri Matias
parent 5d67a3f5f9
commit 7188579e46
5 changed files with 55 additions and 47 deletions

View File

@ -220,7 +220,7 @@ QtObject:
of "alias": result = (message.alias)
of "localName": result = (message.localName)
of "ensName": result = (message.ensName)
of "message": result = (message.text)
of "message": result = (self.renderBlock(message))
of "identicon": result = (message.identicon)
of "timestamp": result = $(message.timestamp)
of "image": result = $(message.image)

View File

@ -86,7 +86,6 @@ StackLayout {
}
}
function showReplyArea() {
isReply = true;
isImage = false;

View File

@ -74,41 +74,7 @@ Item {
if(isEmoji) {
return Emoji.parse(msg, Emoji.size.middle);
} else {
return `<style type="text/css">` +
`p, img, a, del, code, blockquote { margin: 0; padding: 0; }` +
`code {` +
`background-color: ${Style.current.codeBackground};` +
`color: ${Style.current.white};` +
`white-space: pre;` +
`}` +
`p {` +
`line-height: 22px;` +
`}` +
`a {` +
`color: ${isCurrentUser && !appSettings.useCompactMode ? Style.current.white : Style.current.textColor};` +
`}` +
`a.mention {` +
`color: ${Style.current.mentionColor};` +
`background-color: ${Style.current.mentionBgColor};` +
`text-decoration: none;` +
`}` +
`del {` +
`text-decoration: line-through;` +
`}` +
`table.blockquote td {` +
`padding-left: 10px;` +
`color: ${isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText};` +
`}` +
`table.blockquote td.quoteline {` +
`background-color: ${isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText};` +
`height: 100%;` +
`padding-left: 0;` +
`}` +
`.emoji {` +
`vertical-align: bottom;` +
`}` +
`</style>` +
`${Emoji.parse(msg)}`
return Utils.getMessageWithStyle(Emoji.parse(msg), appSettings.useCompactMode, isCurrentUser)
}
}
}

View File

@ -49,6 +49,44 @@ QtObject {
return Style.current.accountColors[colorIndex]
}
function getMessageWithStyle(msg, useCompactMode, isCurrentUser) {
return `<style type="text/css">` +
`p, img, a, del, code, blockquote { margin: 0; padding: 0; }` +
`code {` +
`background-color: ${Style.current.codeBackground};` +
`color: ${Style.current.white};` +
`white-space: pre;` +
`}` +
`p {` +
`line-height: 22px;` +
`}` +
`a {` +
`color: ${isCurrentUser && !useCompactMode ? Style.current.white : Style.current.textColor};` +
`}` +
`a.mention {` +
`color: ${Style.current.mentionColor};` +
`background-color: ${Style.current.mentionBgColor};` +
`text-decoration: none;` +
`}` +
`del {` +
`text-decoration: line-through;` +
`}` +
`table.blockquote td {` +
`padding-left: 10px;` +
`color: ${isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText};` +
`}` +
`table.blockquote td.quoteline {` +
`background-color: ${isCurrentUser ? Style.current.chatReplyCurrentUser : Style.current.secondaryText};` +
`height: 100%;` +
`padding-left: 0;` +
`}` +
`.emoji {` +
`vertical-align: bottom;` +
`}` +
`</style>` +
`${msg}`
}
function getAppSectionIndex(section) {
let sectionId = -1
switch (section) {

View File

@ -38,21 +38,26 @@ Rectangle {
font.weight: Font.Medium
}
StyledText {
id: replyText
text: Emoji.parse(message)
Rectangle {
anchors.left: replyToUsername.left
anchors.top: replyToUsername.bottom
anchors.topMargin: 2
anchors.topMargin: -3
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
anchors.bottom: parent.bottom
elide: Text.ElideRight
font.pixelSize: 13
font.weight: Font.Normal
// Eliding only works for PlainText: https://bugreports.qt.io/browse/QTBUG-16567
textFormat: Text.PlainText
color: Style.current.textColor
clip: true
color: Style.current.transparent
StyledText {
id: replyText
text: Utils.getMessageWithStyle(Utils.linkifyAndXSS(Emoji.parse(message)), appSettings.useCompactMode, false)
anchors.fill: parent
elide: Text.ElideRight
font.pixelSize: 13
font.weight: Font.Normal
textFormat: Text.RichText
color: Style.current.textColor
}
}
RoundButton {