Two more message types on chat list

This commit is contained in:
Sebastian J. Wolf 2020-08-21 12:53:03 +02:00
parent 543ba5d46b
commit bfbc310bc9
4 changed files with 25 additions and 1 deletions

View file

@ -16,6 +16,7 @@
You should have received a copy of the GNU General Public License
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
*/
function getUserName(userInformation) {
var firstName = typeof userInformation.first_name !== "undefined" ? userInformation.first_name : "";
var lastName = typeof userInformation.last_name !== "undefined" ? userInformation.last_name : "";
@ -26,6 +27,9 @@ function getSimpleMessageText(message) {
if (message.content['@type'] === 'messageText') {
return message.content.text.text;
}
if (message.content['@type'] === 'messageSticker') {
return qsTr("Sticker: %1").arg(message.content.sticker.emoji);
}
if (message.content['@type'] === 'messagePhoto') {
return (typeof message.content.caption) ? qsTr("Picture: %1").arg(message.content.caption.text) : qsTr("Picture");
}
@ -38,6 +42,9 @@ function getSimpleMessageText(message) {
if (message.content['@type'] === 'messageChatJoinByLink') {
return qsTr("joined this chat by link.");
}
if (message.content['@type'] === 'messageChatAddMembers') {
return qsTr("was added to this chat.");
}
return "?";
}

View file

@ -217,6 +217,7 @@ Page {
if (overviewPage.chatListCreated) {
// Force update of all list item elements. dataChanged() doesn't seem to trigger them all :(
chatListPictureThumbnail.photoData = (typeof display.photo !== "undefined") ? display.photo.small : "";
chatUnreadMessagesCountBackground.visible = display.unread_count > 0;
chatUnreadMessagesCount.text = display.unread_count > 99 ? "99+" : display.unread_count;
chatListNameText.text = display.title !== "" ? Emoji.emojify(display.title, Theme.fontSizeMedium) : qsTr("Unknown");
chatListLastMessageText.text = (typeof display.last_message !== "undefined") ? Emoji.emojify(Functions.getSimpleMessageText(display.last_message), Theme.fontSizeExtraSmall) : qsTr("Unknown");
@ -308,7 +309,7 @@ Page {
Row {
id: chatListLastMessageRow
width: parent.width
spacing: Theme.paddingMedium
spacing: Theme.paddingSmall
Text {
id: 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)), font.pixelSize) : qsTr("You") ) : qsTr("Unknown")

View file

@ -223,5 +223,13 @@
<source>joined this chat by link.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sticker: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>was added to this chat.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -223,5 +223,13 @@
<source>joined this chat by link.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Sticker: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>was added to this chat.</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>