Some work on reply management, still some work to do...
This commit is contained in:
parent
402c0ed671
commit
a24bf81355
3 changed files with 42 additions and 24 deletions
|
@ -27,25 +27,17 @@ Row {
|
|||
id: inReplyToRow
|
||||
spacing: Theme.paddingSmall
|
||||
width: parent.width
|
||||
visible: originalMessageId !== "0"
|
||||
|
||||
property string originalMessageId: "0";
|
||||
property variant inReplyToMessage;
|
||||
property string myUserId;
|
||||
property variant inReplyToMessage: "";
|
||||
|
||||
onOriginalMessageIdChanged: {
|
||||
if (originalMessageId !== "0") {
|
||||
tdLibWrapper.getMessage(chatInformation.id, originalMessageId);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: tdLibWrapper
|
||||
onReceivedMessage: {
|
||||
if (messageId === originalMessageId) {
|
||||
inReplyToRow.inReplyToMessage = message;
|
||||
inReplyToUserText.text = (inReplyToRow.inReplyToMessage.sender_user_id !== chatPage.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_user_id)), inReplyToUserText.font.pixelSize) : qsTr("You");
|
||||
onInReplyToMessageChanged: {
|
||||
if (typeof inReplyToRow.inReplyToMessage === "object") {
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
inReplyToUserText.text = "";
|
||||
inReplyToMessageText.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ Page {
|
|||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
onClicked: {
|
||||
newMessageColumn.replyToMessageId = display.id;
|
||||
newMessageInReplyToRow.inReplyToMessage = display;
|
||||
sendMessageColumn.focus = true;
|
||||
}
|
||||
text: qsTr("Reply to Message")
|
||||
|
@ -333,6 +333,22 @@ Page {
|
|||
width: messageBackground.width - Theme.horizontalPageMargin
|
||||
anchors.centerIn: messageBackground
|
||||
|
||||
Component.onCompleted: {
|
||||
if (display.reply_to_message_id !== 0) {
|
||||
tdLibWrapper.getMessage(chatInformation.id, display.reply_to_message_id);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: tdLibWrapper
|
||||
onReceivedMessage: {
|
||||
if (messageId === display.reply_to_message_id.toString()) {
|
||||
messageInReplyToRow.inReplyToMessage = message;
|
||||
messageInReplyToRow.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: userText
|
||||
|
||||
|
@ -349,7 +365,9 @@ Page {
|
|||
}
|
||||
|
||||
InReplyToRow {
|
||||
originalMessageId: display.reply_to_message_id
|
||||
id: messageInReplyToRow
|
||||
myUserId: chatPage.myUserId
|
||||
visible: false
|
||||
}
|
||||
|
||||
Text {
|
||||
|
@ -445,11 +463,20 @@ Page {
|
|||
width: parent.width - ( 2 * Theme.horizontalPageMargin )
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
property string replyToMessageId: "0"
|
||||
|
||||
InReplyToRow {
|
||||
originalMessageId: newMessageColumn.replyToMessageId
|
||||
onInReplyToMessageChanged: {
|
||||
console.log("This is a reply!");
|
||||
if (typeof newMessageInReplyToRow.inReplyToMessage === "object") {
|
||||
visible: true;
|
||||
} else {
|
||||
visible: false;
|
||||
}
|
||||
}
|
||||
|
||||
id: newMessageInReplyToRow
|
||||
myUserId: chatPage.myUserId
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: false
|
||||
}
|
||||
|
||||
Row {
|
||||
|
@ -471,7 +498,7 @@ Page {
|
|||
labelVisible: false
|
||||
onFocusChanged: {
|
||||
if (!focus) {
|
||||
newMessageColumn.replyToMessageId = "0";
|
||||
newMessageInReplyToRow.inReplyToMessage = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,6 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages)
|
|||
while (messagesIterator.hasNext()) {
|
||||
QVariantMap currentMessage = messagesIterator.next().toMap();
|
||||
if (currentMessage.value("chat_id").toString() == this->chatId) {
|
||||
|
||||
this->messagesToBeAdded.append(currentMessage);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue