mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-18 09:37:59 +00:00
fix(@desktop/chat): support to mentions in message edit mode
This commit is contained in:
parent
0ef1dee5ce
commit
544b0aafc7
@ -15,7 +15,7 @@ import "../ContactsColumn"
|
||||
import "../CommunityComponents"
|
||||
|
||||
Item {
|
||||
id: svRoot
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
|
||||
property alias chatLogView: chatLogView
|
||||
@ -26,15 +26,6 @@ Item {
|
||||
property bool loadingMessages: false
|
||||
property real scrollY: chatLogView.visibleArea.yPosition * chatLogView.contentHeight
|
||||
property int newMessages: 0
|
||||
|
||||
ScrollView {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
contentHeight: childrenRect.height
|
||||
contentItem: chatLogView
|
||||
ScrollBar.vertical.policy: chatLogView.contentHeight > chatLogView.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
|
||||
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
||||
|
||||
property int countOnStartUp: 0
|
||||
|
||||
ListView {
|
||||
@ -43,6 +34,7 @@ Item {
|
||||
anchors.bottomMargin: Style.current.bigPadding
|
||||
spacing: appSettings.useCompactMode ? 0 : 4
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
clip: true
|
||||
flickDeceleration: {
|
||||
if (utilsModel.getOs() === Constants.windows) {
|
||||
return 5000
|
||||
@ -58,6 +50,7 @@ Item {
|
||||
height: 0
|
||||
width: chatLogView.width
|
||||
}
|
||||
|
||||
function checkHeaderHeight() {
|
||||
if (!chatLogView.headerItem) {
|
||||
return
|
||||
@ -81,6 +74,10 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
visible: chatLogView.visibleArea.heightRatio < 1
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: contentHeightConnection
|
||||
enabled: true
|
||||
@ -309,7 +306,7 @@ Item {
|
||||
z = index;
|
||||
}
|
||||
}
|
||||
messageContextMenu: svRoot.messageContextMenuInst
|
||||
messageContextMenu: root.messageContextMenuInst
|
||||
|
||||
prevMessageIndex: {
|
||||
// This is used in order to have access to the previous message and determine the timestamp
|
||||
@ -332,11 +329,4 @@ Item {
|
||||
modelLoadingDelayTimer.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*##^##
|
||||
Designer {
|
||||
D{i:0;autoSize:true;height:480;width:640}
|
||||
}
|
||||
##^##*/
|
||||
|
@ -24,6 +24,14 @@ Item {
|
||||
height: messageContainer.height + messageContainer.anchors.topMargin
|
||||
+ (dateGroupLbl.visible ? dateGroupLbl.height + dateGroupLbl.anchors.topMargin : 0)
|
||||
|
||||
Timer {
|
||||
id: ensureMessageFullyVisibleTimer
|
||||
interval: 1
|
||||
onTriggered: {
|
||||
chatLogView.positionViewAtIndex(ListView.currentIndex, ListView.Contain)
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
enabled: !placeholderMessage
|
||||
anchors.fill: messageContainer
|
||||
@ -195,16 +203,38 @@ Item {
|
||||
sourceComponent: Item {
|
||||
id: editText
|
||||
height: childrenRect.height
|
||||
|
||||
property bool suggestionsOpened: false
|
||||
Keys.onEscapePressed: {
|
||||
if (!suggestionsOpened) {
|
||||
cancelBtn.clicked()
|
||||
}
|
||||
suggestionsOpened = false
|
||||
}
|
||||
|
||||
StatusChatInput {
|
||||
id: editTextInput
|
||||
readonly property string originalText: Utils.getMessageWithStyle(Emoji.parse(message))
|
||||
Component.onCompleted: {
|
||||
textInput.forceActiveFocus();
|
||||
suggestionsList.clear()
|
||||
for (let i = 0; i < chatInput.suggestionsList.count; i++) {
|
||||
suggestionsList.append(chatInput.suggestionsList.get(i))
|
||||
}
|
||||
textInput.forceActiveFocus()
|
||||
textInput.cursorPosition = textInput.length
|
||||
}
|
||||
id: editTextInput
|
||||
chatInputPlaceholder: qsTrId("type-a-message-")
|
||||
chatType: chatsModel.channelView.activeChannel.chatType
|
||||
isEdit: true
|
||||
textInput.text: Utils.getMessageWithStyle(Emoji.parse(message.replace(/(<a href="\/\/0x[0-9A-Fa-f]+" class="mention">)/g, "$1@")))
|
||||
textInput.text: originalText
|
||||
onSendMessage: {
|
||||
saveBtn.clicked()
|
||||
}
|
||||
suggestions.onVisibleChanged: {
|
||||
if (suggestions.visible) {
|
||||
editText.suggestionsOpened = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatusButton {
|
||||
@ -218,6 +248,7 @@ Item {
|
||||
onClicked: {
|
||||
isEdit = false
|
||||
editTextInput.textInput.text = Emoji.parse(message)
|
||||
ensureMessageFullyVisibleTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +259,7 @@ Item {
|
||||
anchors.top: editTextInput.bottom
|
||||
//% "Save"
|
||||
text: qsTrId("save")
|
||||
enabled: editTextInput.textInput.text.trim().length > 0
|
||||
onClicked: {
|
||||
let msg = chatsModel.plainText(Emoji.deparse(editTextInput.textInput.text))
|
||||
if (msg.length > 0){
|
||||
|
@ -143,10 +143,12 @@ ModalPopup {
|
||||
reactionModel: EmojiReactions { }
|
||||
|
||||
onCloseParentPopup: {
|
||||
if (messageItem.view) {
|
||||
messageItem.view.closePopup()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
|
Loading…
x
Reference in New Issue
Block a user