Now able to pin messages and show in-reply-to messages in overlay

This commit is contained in:
Sebastian Wolf 2020-11-17 20:25:57 +01:00
parent 541036d796
commit b35d268b12
15 changed files with 138 additions and 43 deletions

View file

@ -101,6 +101,36 @@ ListItem {
}
text: qsTr("Select Message")
}
MenuItem {
function amIVisible() {
console.log("Is pin message menu visible?");
if (page.isPrivateChat) {
console.log("Private Chat: No!");
return false;
}
if (page.chatGroupInformation.status["@type"] === "chatMemberStatusCreator") {
console.log("Creator of this chat: Yes!");
return true;
}
if (page.chatInformation.permissions.can_pin_messages) {
console.log("All people can pin: Yes!");
return true;
}
if (page.chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator") {
console.log("Admin with privileges? " + page.chatGroupInformation.status.can_pin_messages);
return page.chatGroupInformation.status.can_pin_messages;
}
console.log("Something else: No!");
return false;
}
onClicked: {
tdLibWrapper.pinMessage(page.chatInformation.id, myMessage.id);
}
text: qsTr("Pin Message")
visible: amIVisible()
}
MenuItem {
onClicked: {
var chatId = page.chatInformation.id;
@ -277,12 +307,23 @@ ListItem {
height: active ? precalculatedValues.messageInReplyToHeight : 0
property var inReplyToMessage;
sourceComponent: Component {
Item {
width: messageInReplyToRow.width
height: messageInReplyToRow.height
InReplyToRow {
id: messageInReplyToRow
myUserId: page.myUserId
visible: true
inReplyToMessage: messageInReplyToLoader.inReplyToMessage
}
MouseArea {
anchors.fill: parent
onClicked: {
messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage;
messageOverlayLoader.active = true;
}
}
}
}
}

View file

@ -67,11 +67,14 @@ Item {
}
}
Item {
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
height: pinnedMessageColumn.height
anchors.verticalCenter: parent.verticalCenter
Column {
id: pinnedMessageColumn
spacing: Theme.paddingSmall
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
anchors.verticalCenter: parent.verticalCenter
width: parent.width
Text {
id: pinnedMessageUserText
@ -84,12 +87,6 @@ Item {
elide: Text.ElideRight
textFormat: Text.StyledText
horizontalAlignment: Text.AlignLeft
MouseArea {
anchors.fill: parent
onClicked: {
pinnedMessageItem.requestShowMessage();
}
}
}
Text {
@ -101,6 +98,8 @@ Item {
elide: Text.ElideRight
maximumLineCount: 1
textFormat: Text.StyledText
}
}
MouseArea {
anchors.fill: parent
onClicked: {
@ -108,7 +107,6 @@ Item {
}
}
}
}
IconButton {
id: removePinnedMessageIconButton

View file

@ -292,6 +292,17 @@ void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId,
this->sendRequest(requestObject);
}
void TDLibWrapper::pinMessage(const QString &chatId, const QString &messageId, bool disableNotification)
{
LOG("Pin message to chat" << chatId << messageId << disableNotification);
QVariantMap requestObject;
requestObject.insert(_TYPE, "pinChatMessage");
requestObject.insert("chat_id", chatId);
requestObject.insert("message_id", messageId);
requestObject.insert("disable_notification", disableNotification);
this->sendRequest(requestObject);
}
void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId)
{
LOG("Sending text message" << chatId << message << replyToMessageId);

View file

@ -122,6 +122,7 @@ public:
Q_INVOKABLE void leaveChat(const QString &chatId);
Q_INVOKABLE void getChatHistory(qlonglong chatId, const qlonglong &fromMessageId = 0, int offset = 0, int limit = 50, bool onlyLocal = false);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId, bool force);
Q_INVOKABLE void pinMessage(const QString &chatId, const QString &messageId, bool disableNotification = false);
Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");

View file

@ -839,6 +839,10 @@
<source>Select Message</source>
<translation>Nachricht auswählen</translation>
</message>
<message>
<source>Pin Message</source>
<translation>Nachricht anheften</translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>
@ -851,11 +855,11 @@
<name>MessageOverlayFlickable</name>
<message>
<source>You</source>
<translation type="unfinished">Sie</translation>
<translation>Sie</translation>
</message>
<message>
<source>This message was forwarded. Original author: %1</source>
<translation type="unfinished"></translation>
<translation>Diese Nachricht wurde weitergeleitet. Ursprünglicher Autor: %1</translation>
</message>
</context>
<context>
@ -912,11 +916,11 @@
<name>PinnedMessageItem</name>
<message>
<source>You</source>
<translation type="unfinished">Sie</translation>
<translation>Sie</translation>
</message>
<message>
<source>Pinned Message</source>
<translation type="unfinished"></translation>
<translation>Angeheftete Nachricht</translation>
</message>
</context>
<context>

View file

@ -839,6 +839,10 @@
<source>Select Message</source>
<translation>Select Message</translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -835,6 +835,10 @@
<source>Select Message</source>
<translation>Seleccionar mensaje</translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -840,6 +840,10 @@
<source>Select Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -835,6 +835,10 @@
<source>Select Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -839,6 +839,10 @@
<source>Select Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -843,6 +843,10 @@
<source>Select Message</source>
<translation>Wybierz wiadomość</translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -843,6 +843,10 @@
<source>Select Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -839,6 +839,10 @@
<source>Select Message</source>
<translation>Välj meddelande</translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -835,6 +835,10 @@
<source>Select Message</source>
<translation></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>

View file

@ -835,6 +835,10 @@
<source>Select Message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Pin Message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageListViewItemSimple</name>