Differentiate text between other people and user

This commit is contained in:
Sebastian J. Wolf 2020-09-30 00:09:51 +02:00
parent 97e72bac9b
commit bfe3084d2e
10 changed files with 374 additions and 20 deletions

View file

@ -34,7 +34,7 @@ Row {
onInReplyToMessageChanged: {
if (inReplyToMessage) {
inReplyToUserText.text = (inReplyToRow.inReplyToMessage.sender_user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_user_id)), inReplyToUserText.font.pixelSize) : qsTr("You");
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true), inReplyToMessageText.font.pixelSize);
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true, inReplyToRow.inReplyToMessage.sender_user_id === inReplyToRow.myUserId), inReplyToMessageText.font.pixelSize);
}
}

View file

@ -23,7 +23,7 @@ function getUserName(userInformation) {
return (firstName + " " + lastName).trim();
}
function getMessageText(message, simple) {
function getMessageText(message, simple, myself) {
if (message.content['@type'] === 'messageText') {
if (simple) {
return message.content.text.text;
@ -38,61 +38,61 @@ function getMessageText(message, simple) {
if (message.content.caption.text !== "") {
return simple ? qsTr("Picture: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
} else {
return simple ? qsTr("sent a picture") : "";
return simple ? (myself ? qsTr("sent a picture", "myself") : qsTr("sent a picture")) : "";
}
}
if (message.content['@type'] === 'messageVideo') {
if (message.content.caption.text !== "") {
return simple ? qsTr("Video: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
} else {
return simple ? qsTr("sent a video") : "";
return simple ? (myself ? qsTr("sent a video", "myself") : qsTr("sent a video")) : "";
}
}
if (message.content['@type'] === 'messageAnimation') {
if (message.content.caption.text !== "") {
return simple ? qsTr("Animation: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
} else {
return simple ? qsTr("sent an animation") : "";
return simple ? (myself ? qsTr("sent an animation", "myself") : qsTr("sent an animation")) : "";
}
}
if (message.content['@type'] === 'messageAudio') {
if (message.content.caption.text !== "") {
return simple ? qsTr("Audio: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
} else {
return simple ? qsTr("sent an audio") : "";
return simple ? (myself ? qsTr("sent an audio", "myself") : qsTr("sent an audio")) : "";
}
}
if (message.content['@type'] === 'messageVoiceNote') {
if (message.content.caption.text !== "") {
return simple ? qsTr("Voice Note: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
} else {
return simple ? qsTr("sent a voice note") : "";
return simple ? (myself ? qsTr("sent a voice note", "myself") : qsTr("sent a voice note")) : "";
}
}
if (message.content['@type'] === 'messageDocument') {
if (message.content.document.file_name !== "") {
return simple ? qsTr("Document: %1").arg(message.content.document.file_name) : message.content.document.file_name
} else {
return simple ? qsTr("sent a document") : "";
return simple ? (myself ? qsTr("sent a document", "myself") : qsTr("sent a document")) : "";
}
}
if (message.content['@type'] === 'messageLocation') {
return simple ? qsTr("sent a location") : "";
return simple ? (myself ? qsTr("sent a location", "myself") : qsTr("sent a location")) : "";
}
if (message.content['@type'] === 'messageVenue') {
return simple ? qsTr("sent a venue") : ( "<b>" + message.content.venue.title + "</b>, " + message.content.venue.address );
return simple ? (myself ? qsTr("sent a venue", "myself") : qsTr("sent a venue")) : ( "<b>" + message.content.venue.title + "</b>, " + message.content.venue.address );
}
if (message.content['@type'] === 'messageContactRegistered') {
return qsTr("has registered with Telegram");
return myself ? qsTr("have registered with Telegram") : qsTr("has registered with Telegram");
}
if (message.content['@type'] === 'messageChatJoinByLink') {
return qsTr("joined this chat");
return myself ? qsTr("joined this chat", "myself") : qsTr("joined this chat");
}
if (message.content['@type'] === 'messageChatAddMembers') {
return qsTr("was added to this chat");
return myself ? qsTr("were added to this chat", "myself") : qsTr("was added to this chat");
}
if (message.content['@type'] === 'messageChatDeleteMember') {
return qsTr("left this chat");
return myself ? qsTr("left this chat", "myself") : qsTr("left this chat");
}
return qsTr("Unsupported message: %1").arg(message.content['@type'].substring(7));
}

View file

@ -458,7 +458,7 @@ Page {
MenuItem {
onClicked: {
newMessageColumn.editMessageId = display.id;
newMessageTextField.text = Functions.getMessageText(display, false);
newMessageTextField.text = Functions.getMessageText(display, false, false);
newMessageTextField.focus = true;
}
text: qsTr("Edit Message")
@ -610,7 +610,7 @@ Page {
id: messageText
width: parent.width
text: Emoji.emojify(Functions.getMessageText(display, false), font.pixelSize)
text: Emoji.emojify(Functions.getMessageText(display, false, chatPage.myUserId === display.sender_user_id), font.pixelSize)
font.pixelSize: Theme.fontSizeSmall
color: (chatPage.myUserId === display.sender_user_id) ? Theme.highlightColor : Theme.primaryColor
wrapMode: Text.Wrap
@ -773,7 +773,7 @@ Page {
if (index === modelIndex) {
console.log("[ChatModel] This message was updated, index " + index + ", updating content...");
messageDateText.text = getMessageStatusText(display, index, chatView.lastReadSentIndex);
messageText.text = Emoji.emojify(Functions.getMessageText(display, false), messageText.font.pixelSize);
messageText.text = Emoji.emojify(Functions.getMessageText(display, false, chatPage.myUserId === display.sender_user_id), messageText.font.pixelSize);
if(locationPreviewLoader.active && locationPreviewLoader.status === Loader.Ready) {
locationPreviewLoader.item.locationData = display.content.location;
locationPreviewLoader.item.updatePicture()

View file

@ -256,7 +256,7 @@ Page {
chatUnreadMessagesCount.text = display.unread_count > 99 ? "99+" : display.unread_count;
chatListNameText.text = display.title !== "" ? Emoji.emojify(display.title, Theme.fontSizeMedium) + ( display.notification_settings.mute_for > 0 ? Emoji.emojify(" 🔇", Theme.fontSizeMedium) : "" ) : qsTr("Unknown");
chatListLastUserText.text = (typeof display.last_message !== "undefined") ? ( display.last_message.sender_user_id !== overviewPage.ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(display.last_message.sender_user_id)), Theme.fontSizeExtraSmall) : qsTr("You") ) : qsTr("Unknown");
chatListLastMessageText.text = (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true), Theme.fontSizeExtraSmall) : qsTr("Unknown");
chatListLastMessageText.text = (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true, display.last_message.sender_user_id === overviewPage.ownUserId), Theme.fontSizeExtraSmall) : qsTr("Unknown");
messageContactTimeElapsedText.text = (typeof display.last_message !== "undefined") ? Functions.getDateTimeElapsed(display.last_message.date) : qsTr("Unknown");
}
}
@ -362,7 +362,7 @@ Page {
}
Text {
id: chatListLastMessageText
text: (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true), Theme.fontSizeExtraSmall) : qsTr("Unknown")
text: (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true, display.last_message.sender_user_id === overviewPage.ownUserId), Theme.fontSizeExtraSmall) : qsTr("Unknown")
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.primaryColor
width: parent.width - Theme.paddingMedium - chatListLastUserText.width
@ -392,7 +392,7 @@ Page {
chatUnreadMessagesCount.text = display.unread_count > 99 ? "99+" : display.unread_count;
chatListNameText.text = display.title !== "" ? Emoji.emojify(display.title, Theme.fontSizeMedium) + ( display.notification_settings.mute_for > 0 ? Emoji.emojify(" 🔇", Theme.fontSizeMedium) : "" ) : qsTr("Unknown");
chatListLastUserText.text = (typeof display.last_message !== "undefined") ? ( display.last_message.sender_user_id !== overviewPage.ownUserId ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(display.last_message.sender_user_id)), Theme.fontSizeExtraSmall) : qsTr("You") ) : qsTr("Unknown");
chatListLastMessageText.text = (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true), Theme.fontSizeExtraSmall) : qsTr("Unknown");
chatListLastMessageText.text = (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getMessageText(display.last_message, true, display.last_message.sender_user_id === overviewPage.ownUserId), Theme.fontSizeExtraSmall) : qsTr("Unknown");
}
}
}

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation>hat einen Ort geschickt</translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation>haben ein Bild geschickt</translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation>haben ein Video geschickt</translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation>haben eine Animation geschickt</translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation>haben eine Audiodatei geschickt</translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation>haben eine Sprachnachricht geschickt</translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation>haben ein Dokument geschickt</translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation>haben einen Standort geschickt</translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation>haben einen Ort geschickt</translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation>haben sich bei Telegram angemeldet</translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation>sind diesem Chat beigetreten</translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation>wurde diesem Chat hinzugefügt</translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation>haben diesen Chat verlassen</translation>
</message>
</context>
</TS>

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation type="unfinished">envió una imagen</translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation type="unfinished">envió un video</translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation type="unfinished">envió una animación</translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation type="unfinished">envió un audio</translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation type="unfinished">envió una nota de voz</translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation type="unfinished">envió un documento</translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation type="unfinished">envió una ubicación</translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation type="unfinished">se unió a esta charla</translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation type="unfinished">dejó esta charla</translation>
</message>
</context>
</TS>

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation type="unfinished">képet küldött</translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation type="unfinished">videót küldött</translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation type="unfinished">animációt küldött</translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation type="unfinished">audiót küldött</translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation type="unfinished">hangüzenetet küldött</translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation type="unfinished">helyzetmeghatározó információt küldött</translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation type="unfinished">csatlakozott a csevegéshez</translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation type="unfinished">kilépett a csevegésből</translation>
</message>
</context>
</TS>

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation type="unfinished">wyślij obraz</translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation type="unfinished">wyślij film</translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation type="unfinished">wyślij animację</translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation type="unfinished">wyślij dźwięk</translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation type="unfinished">wyślij notatke głosową</translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation type="unfinished">wyślij dokument</translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation type="unfinished">wyślij lokalizację</translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -526,5 +526,64 @@
<source>sent a venue</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a picture</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a video</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent an animation</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent an audio</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a voice note</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a document</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a location</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>sent a venue</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>have registered with Telegram</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>joined this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>were added to this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>left this chat</source>
<comment>myself</comment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>