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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ Item {
signal openStickerPackPopup(string stickerPackId)
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 replyClicked(string messageId, string author)
width: parent.width
height: messageContainer.height + messageContainer.anchors.topMargin
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
@ -89,7 +89,7 @@ Item {
root.clickMessage(isProfileClick, isSticker, isImage, image, emojiOnly, hideEmojiPicker, false, false, "");
}
onReplyClicked: {
showReplyArea();
root.replyClicked(messageId, author)
}
}

View File

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