fix(Replies): Fix reply button

Closes: #4396
This commit is contained in:
Boris Melnik 2022-01-12 15:55:26 +03:00 committed by Sale Djenic
parent b43b073f5f
commit 35568d1d6b
7 changed files with 101 additions and 76 deletions

View File

@ -84,10 +84,10 @@ ColumnLayout {
return return
} }
Global.openPopup(pinnedMessagesPopupComponent, { Global.openPopup(pinnedMessagesPopupComponent, {
messageStore: messageStore, messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel, pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: "" messageToPin: ""
}) })
} }
chatInfoButton.onUnmute: { chatInfoButton.onUnmute: {
if(!chatContentModule) { if(!chatContentModule) {
@ -106,17 +106,17 @@ ColumnLayout {
} }
chatInfoButton.onClicked: { chatInfoButton.onClicked: {
// Not Refactored Yet // Not Refactored Yet
// switch (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType) { // switch (chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.chatType) {
// case Constants.chatType.privateGroupChat: // case Constants.chatType.privateGroupChat:
// openPopup(groupInfoPopupComponent, { // openPopup(groupInfoPopupComponent, {
// channelType: GroupInfoPopup.ChannelType.ActiveChannel, // channelType: GroupInfoPopup.ChannelType.ActiveChannel,
// channel: chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel // channel: chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel
// }) // })
// break; // break;
// case Constants.chatType.oneToOne: // case Constants.chatType.oneToOne:
// openProfilePopup(chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.id) // openProfilePopup(chatContentRoot.rootStore.chatsModelInst.channelView.activeChannel.id)
// break; // break;
// } // }
} }
membersButton.visible: { membersButton.visible: {
@ -257,26 +257,26 @@ ColumnLayout {
} }
// Not Refactored Yet // Not Refactored Yet
// Connections { // Connections {
// target: chatContentRoot.rootStore.chatsModelInst // target: chatContentRoot.rootStore.chatsModelInst
// onOnlineStatusChanged: { // onOnlineStatusChanged: {
// if (connected == isConnected) return; // if (connected == isConnected) return;
// isConnected = connected; // isConnected = connected;
// if(isConnected){ // if(isConnected){
// timer.setTimeout(function(){ // timer.setTimeout(function(){
// connectedStatusRect.visible = false; // connectedStatusRect.visible = false;
// }, 5000); // }, 5000);
// } else { // } else {
// connectedStatusRect.visible = true; // connectedStatusRect.visible = true;
// } // }
// } // }
// } // }
// Component.onCompleted: { // Component.onCompleted: {
// isConnected = chatContentRoot.rootStore.chatsModelInst.isOnline // isConnected = chatContentRoot.rootStore.chatsModelInst.isOnline
// if(!isConnected){ // if(!isConnected){
// connectedStatusRect.visible = true // connectedStatusRect.visible = true
// } // }
// } // }
} }
Item { Item {
@ -322,10 +322,10 @@ ColumnLayout {
return return
} }
Global.openPopup(pinnedMessagesPopupComponent, { Global.openPopup(pinnedMessagesPopupComponent, {
messageStore: messageStore, messageStore: messageStore,
pinnedMessagesModel: chatContentModule.pinnedMessagesModel, pinnedMessagesModel: chatContentModule.pinnedMessagesModel,
messageToPin: messageId messageToPin: messageId
}) })
} }
onToggleReaction: { onToggleReaction: {
@ -351,6 +351,14 @@ ColumnLayout {
messageContextMenuInst: contextmenu messageContextMenuInst: contextmenu
messageStore: messageStore messageStore: messageStore
stickersLoaded: chatContentRoot.stickersLoaded stickersLoaded: chatContentRoot.stickersLoaded
onShowReplyArea: {
let obj = messageStore.getMessageByIdAsJson(messageId)
if (!obj) {
return
}
chatInput.showReplyArea(messageId, obj.senderDisplayName, obj.messageText, obj.senderIcon, obj.contentType, obj.messageImage, obj.sticker)
}
} }
Item { Item {
@ -362,33 +370,33 @@ ColumnLayout {
Layout.preferredHeight: height Layout.preferredHeight: height
// Not Refactored Yet // Not Refactored Yet
// Connections { // Connections {
// target: chatContentRoot.rootStore.chatsModelInst.messageView // target: chatContentRoot.rootStore.chatsModelInst.messageView
// onLoadingMessagesChanged: // onLoadingMessagesChanged:
// if(value){ // if(value){
// loadingMessagesIndicator.active = true // loadingMessagesIndicator.active = true
// } else { // } else {
// timer.setTimeout(function(){ // timer.setTimeout(function(){
// loadingMessagesIndicator.active = false; // loadingMessagesIndicator.active = false;
// }, 5000); // }, 5000);
// } // }
// } // }
// Not Refactored Yet // Not Refactored Yet
// Loader { // Loader {
// id: loadingMessagesIndicator // id: loadingMessagesIndicator
// active: chatContentRoot.rootStore.chatsModelInst.messageView.loadingMessages // active: chatContentRoot.rootStore.chatsModelInst.messageView.loadingMessages
// sourceComponent: loadingIndicator // sourceComponent: loadingIndicator
// anchors.right: parent.right // anchors.right: parent.right
// anchors.bottom: chatInput.top // anchors.bottom: chatInput.top
// anchors.rightMargin: Style.current.padding // anchors.rightMargin: Style.current.padding
// anchors.bottomMargin: Style.current.padding // anchors.bottomMargin: Style.current.padding
// } // }
// Component { // Component {
// id: loadingIndicator // id: loadingIndicator
// LoadingAnimation { } // LoadingAnimation { }
// } // }
StatusChatInput { StatusChatInput {
id: chatInput id: chatInput
@ -434,9 +442,9 @@ ColumnLayout {
} }
onStickerSelected: { onStickerSelected: {
chatContentRoot.rootStore.sendSticker(chatContentModule.getMyChatId(), chatContentRoot.rootStore.sendSticker(chatContentModule.getMyChatId(),
hashId, hashId,
chatInput.isReply ? SelectedMessage.messageId : "", chatInput.isReply ? SelectedMessage.messageId : "",
packId) packId)
} }
onSendMessage: { onSendMessage: {
if(!chatContentModule) { if(!chatContentModule) {
@ -452,10 +460,10 @@ ColumnLayout {
msg = chatInput.interpretMessage(msg) msg = chatInput.interpretMessage(msg)
chatContentModule.inputAreaModule.sendMessage( chatContentModule.inputAreaModule.sendMessage(
msg, msg,
chatInput.isReply ? SelectedMessage.messageId : "", chatInput.isReply ? chatInput.replyMessageId : "",
Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType, Utils.isOnlyEmoji(msg) ? Constants.messageContentType.emojiType : Constants.messageContentType.messageType,
false) false)
if (event) event.accepted = true if (event) event.accepted = true
sendMessageSound.stop(); sendMessageSound.stop();

View File

@ -36,6 +36,7 @@ Item {
property int countOnStartUp: 0 property int countOnStartUp: 0
signal openStickerPackPopup(string stickerPackId) signal openStickerPackPopup(string stickerPackId)
signal showReplyArea(string messageId, string author)
Item { Item {
id: loadingMessagesIndicator id: loadingMessagesIndicator
@ -346,6 +347,10 @@ Item {
root.openStickerPackPopup(stickerPackId); root.openStickerPackPopup(stickerPackId);
} }
onShowReplyArea: {
root.showReplyArea(messageId, author)
}
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
} }
} }

View File

@ -18,7 +18,7 @@ Rectangle {
property bool placeholderMsg property bool placeholderMsg
property string fromAuthor property string fromAuthor
property alias editBtnActive: editBtn.active property alias editBtnActive: editBtn.active
signal replyClicked() signal replyClicked(string messageId, string author)
signal hoverChanged(bool hovered) signal hoverChanged(bool hovered)
signal setMessageActive(string messageId, bool active) signal setMessageActive(string messageId, bool active)
signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker) signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker)
@ -95,8 +95,7 @@ Rectangle {
//% "Reply" //% "Reply"
tooltip.text: qsTrId("message-reply") tooltip.text: qsTrId("message-reply")
onClicked: { onClicked: {
SelectedMessage.set(messageId, fromAuthor); buttonsContainer.replyClicked(messageId, fromAuthor);
buttonsContainer.replyClicked();
if (messageContextMenu.closeParentPopup) { if (messageContextMenu.closeParentPopup) {
messageContextMenu.closeParentPopup() messageContextMenu.closeParentPopup()
} }

View File

@ -32,6 +32,7 @@ Rectangle {
property bool paste: false; property bool paste: false;
property bool isColonPressed: false; property bool isColonPressed: false;
property bool isReply: false property bool isReply: false
property string replyMessageId: replyArea.messageId
property bool isImage: false property bool isImage: false
property bool isEdit: false property bool isEdit: false
@ -550,7 +551,7 @@ Rectangle {
control.fileUrls = imageArea.imageSource control.fileUrls = imageArea.imageSource
} }
function showReplyArea(userName, message, identicon, contentType, image, sticker) { function showReplyArea(messageId, userName, message, identicon, contentType, image, sticker) {
isReply = true isReply = true
replyArea.userName = userName replyArea.userName = userName
replyArea.message = message replyArea.message = message
@ -558,6 +559,7 @@ Rectangle {
replyArea.contentType = contentType replyArea.contentType = contentType
replyArea.image = image replyArea.image = image
replyArea.stickerData = sticker replyArea.stickerData = sticker
replyArea.messageId = messageId
messageInputField.forceActiveFocus(); messageInputField.forceActiveFocus();
} }

View File

@ -21,6 +21,7 @@ Rectangle {
property string identicon: "" property string identicon: ""
property string image: "" property string image: ""
property string stickerData: "" property string stickerData: ""
property string messageId: ""
property int contentType: -1 property int contentType: -1
signal closeButtonClicked() signal closeButtonClicked()
@ -126,6 +127,10 @@ Rectangle {
root.userName = "" root.userName = ""
root.message = "" root.message = ""
root.identicon = "" root.identicon = ""
root.messageId = ""
root.stickerData = ""
root.image = ""
root.contentType = -1
root.closeButtonClicked() root.closeButtonClicked()
} }
MouseArea { MouseArea {

View File

@ -46,7 +46,7 @@ Item {
signal openStickerPackPopup(string stickerPackId) signal openStickerPackPopup(string stickerPackId)
signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool emojiOnly, bool hideEmojiPicker) signal addEmoji(bool isProfileClick, bool isSticker, bool isImage , var image, bool emojiOnly, bool hideEmojiPicker)
signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker, bool isReply, bool isRightClickOnImage, string imageSource) signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker, bool isReply, bool isRightClickOnImage, string imageSource)
signal replyClicked(string messageId, string author)
width: parent.width width: parent.width
height: messageContainer.height + messageContainer.anchors.topMargin height: messageContainer.height + messageContainer.anchors.topMargin
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0) + (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
@ -89,7 +89,7 @@ Item {
root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, false, false, ""); root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, false, false, "");
} }
onReplyClicked: { onReplyClicked: {
showReplyArea(); root.replyClicked(messageId, author)
} }
} }

View File

@ -185,6 +185,8 @@ Column {
messageContextMenu.popup() messageContextMenu.popup()
} }
signal showReplyArea(string messageId, string author)
// function showReactionAuthors(fromAccounts, emojiId) { // function showReactionAuthors(fromAccounts, emojiId) {
// return root.rootStore.showReactionAuthors(fromAccounts, emojiId) // return root.rootStore.showReactionAuthors(fromAccounts, emojiId)
@ -373,6 +375,10 @@ Column {
onOpenStickerPackPopup: { onOpenStickerPackPopup: {
root.openStickerPackPopup(stickerPackId); root.openStickerPackPopup(stickerPackId);
} }
onReplyClicked: {
root.showReplyArea(messageId, author)
}
} }
} }
} }