Merge pull request #108 from jgibbon/bugfix/remove-path-replacement

Fix emoji paths for chat information Items
This commit is contained in:
Sebastian Wolf 2020-10-27 22:33:13 +01:00 committed by GitHub
commit afb53965b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 8 deletions

View file

@ -79,18 +79,18 @@ ChatInformationTabItemBase {
width: parent.width width: parent.width
// chat title isPrivateChat ? () : // chat title isPrivateChat ? () :
primaryText.text: Emoji.emojify(Functions.getUserName(user), primaryText.font.pixelSize) primaryText.text: Emoji.emojify(Functions.getUserName(user), primaryText.font.pixelSize, "../../js/emoji/")
// last user // last user
prologSecondaryText.text: "@"+(user.username !== "" ? user.username : user_id) + (user_id === chatInformationPage.myUserId ? " " + qsTr("You") : "") prologSecondaryText.text: "@"+(user.username !== "" ? user.username : user_id) + (user_id === chatInformationPage.myUserId ? " " + qsTr("You") : "")
secondaryText { secondaryText {
horizontalAlignment: Text.AlignRight horizontalAlignment: Text.AlignRight
property string statusText: Functions.getChatMemberStatusText(model.status["@type"]) property string statusText: Functions.getChatMemberStatusText(model.status["@type"])
property string customText: model.status.custom_title ? Emoji.emojify(model.status.custom_title, secondaryText.font.pixelSize) : "" property string customText: model.status.custom_title ? Emoji.emojify(model.status.custom_title, secondaryText.font.pixelSize, "../../js/emoji/") : ""
text: (statusText !== "" && customText !== "") ? statusText + ", " + customText : statusText + customText text: (statusText !== "" && customText !== "") ? statusText + ", " + customText : statusText + customText
} }
tertiaryText { tertiaryText {
maximumLineCount: 1 maximumLineCount: 1
text: user.type["@type"] === "userTypeBot" ? (Emoji.emojify("🤖 "+bot_info.description, tertiaryText.font.pixelSize)) : Functions.getChatPartnerStatusText(user.status["@type"], user.status.was_online); text: user.type["@type"] === "userTypeBot" ? (Emoji.emojify("🤖 "+bot_info.description, tertiaryText.font.pixelSize, "../../js/emoji/")) : Functions.getChatPartnerStatusText(user.status["@type"], user.status.was_online);
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -162,7 +162,7 @@ ChatInformationTabItemBase {
onChatChanged: { onChatChanged: {
if (changedChatId === chat_id) { if (changedChatId === chat_id) {
// Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :( // Force update of some list item elements (currently only last message text seems to create problems). dataChanged() doesn't seem to trigger them all :(
secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall) : qsTr("Unknown") secondaryText.text = last_message_text ? Emoji.emojify(last_message_text, Theme.fontSizeExtraSmall, "../../js/emoji/") : qsTr("Unknown")
} }
} }
} }

View file

@ -50,7 +50,7 @@ Column {
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeExtraSmall
textFormat: Text.StyledText textFormat: Text.StyledText
color: Theme.highlightColor color: Theme.highlightColor
text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "<br>"), Theme.fontSizeExtraSmall).replace(/\.\.\/js/g, "../../js") text: Emoji.emojify( Functions.replaceUrlsWithLinks(textItem.text).replace(/\n/g, "<br>"), Theme.fontSizeExtraSmall, "../../js/emoji/")
linkColor: Theme.primaryColor linkColor: Theme.primaryColor
visible: text !== "" visible: text !== ""
onLinkActivated: { onLinkActivated: {

View file

@ -568,8 +568,8 @@ var twemoji = (function (
}()); }());
function emojify(rawText, emojiSize) { function emojify(rawText, emojiSize, basePath) {
var curatedText = twemoji.parse(rawText, { callback: function(icon, options, variant) { return '../js/emoji/' + icon + '.svg'; }, size: emojiSize }); var curatedText = twemoji.parse(rawText, { callback: function(icon, options, variant) { return (basePath || '../js/emoji/') + icon + '.svg'; }, size: emojiSize });
// QML has a weird bug. If an ampersand is followed by an HTML tag or a character, the tag is ignored and returned as string or the following string is omitted // QML has a weird bug. If an ampersand is followed by an HTML tag or a character, the tag is ignored and returned as string or the following string is omitted
// Therefore replacing the ampersand with &amp; in these cases... // Therefore replacing the ampersand with &amp; in these cases...
return curatedText.replace(/((\&[\w\d]+\;)|((\&)(\<|\w+)))/g, function(match, p1, p2, p3, p4, p5, offset, string) { return curatedText.replace(/((\&[\w\d]+\;)|((\&)(\<|\w+)))/g, function(match, p1, p2, p3, p4, p5, offset, string) {

View file

@ -265,8 +265,10 @@ Page {
: "../components/chatInformationPage/ChatInformationProfilePicture.qml" : "../components/chatInformationPage/ChatInformationProfilePicture.qml"
} }
} }
// PageHeader changes the html base path:
property url emojiBase: "../js/emoji/"
leftMargin: imageContainer.minDimension + Theme.horizontalPageMargin + Theme.paddingMedium leftMargin: imageContainer.minDimension + Theme.horizontalPageMargin + Theme.paddingMedium
title: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, Theme.fontSizeLarge) : qsTr("Unknown") title: chatInformation.title !== "" ? Emoji.emojify(chatInformation.title, Theme.fontSizeLarge, emojiBase) : qsTr("Unknown")
description: chatInformationPage.isPrivateChat ? ("@"+(chatInformationPage.privateChatUserInformation.username || chatInformationPage.chatPartnerGroupId)) : "" description: chatInformationPage.isPrivateChat ? ("@"+(chatInformationPage.privateChatUserInformation.username || chatInformationPage.chatPartnerGroupId)) : ""
} }