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 "alias": result = (message.alias)
of "localName": result = (message.localName) of "localName": result = (message.localName)
of "ensName": result = (message.ensName) of "ensName": result = (message.ensName)
of "message": result = (message.text) of "message": result = (self.renderBlock(message))
of "identicon": result = (message.identicon) of "identicon": result = (message.identicon)
of "timestamp": result = $(message.timestamp) of "timestamp": result = $(message.timestamp)
of "image": result = $(message.image) of "image": result = $(message.image)

View File

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

View File

@ -74,41 +74,7 @@ Item {
if(isEmoji) { if(isEmoji) {
return Emoji.parse(msg, Emoji.size.middle); return Emoji.parse(msg, Emoji.size.middle);
} else { } else {
return `<style type="text/css">` + return Utils.getMessageWithStyle(Emoji.parse(msg), appSettings.useCompactMode, isCurrentUser)
`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)}`
} }
} }
} }

View File

@ -49,6 +49,44 @@ QtObject {
return Style.current.accountColors[colorIndex] 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) { function getAppSectionIndex(section) {
let sectionId = -1 let sectionId = -1
switch (section) { switch (section) {

View File

@ -38,22 +38,27 @@ Rectangle {
font.weight: Font.Medium font.weight: Font.Medium
} }
StyledText { Rectangle {
id: replyText
text: Emoji.parse(message)
anchors.left: replyToUsername.left anchors.left: replyToUsername.left
anchors.top: replyToUsername.bottom anchors.top: replyToUsername.bottom
anchors.topMargin: 2 anchors.topMargin: -3
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Style.current.padding anchors.rightMargin: Style.current.padding
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
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 elide: Text.ElideRight
font.pixelSize: 13 font.pixelSize: 13
font.weight: Font.Normal font.weight: Font.Normal
// Eliding only works for PlainText: https://bugreports.qt.io/browse/QTBUG-16567 textFormat: Text.RichText
textFormat: Text.PlainText
color: Style.current.textColor color: Style.current.textColor
} }
}
RoundButton { RoundButton {
id: closeBtn id: closeBtn