Fix autocompletion
Now it will save a map from display name to id and use that to generate clean matrix.to links. This also make sure the colors used for the preview are correct by using NeoChatUser and fix the bug with the regex by simply removing the regex. Fix #234
This commit is contained in:
@@ -138,6 +138,7 @@ ToolBar {
|
||||
keyNavigationWraps: true
|
||||
|
||||
delegate: Control {
|
||||
readonly property string userId: modelData.id ?? ""
|
||||
readonly property string displayText: modelData.displayName ?? modelData.unicode
|
||||
readonly property bool isEmoji: modelData.unicode != null
|
||||
readonly property bool highlighted: autoCompleteListView.currentIndex == index
|
||||
@@ -468,9 +469,14 @@ ToolBar {
|
||||
autoCompleteEndPosition = cursorPosition
|
||||
}
|
||||
|
||||
// store each user we autoComplete here, this will be helpful later to generate
|
||||
// the matrix.to links.
|
||||
// This use an hack to define: https://doc.qt.io/qt-5/qml-var.html#property-value-initialization-semantics
|
||||
property var userAutocompleted: ({})
|
||||
|
||||
function postMessage() {
|
||||
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
|
||||
replyEventID, editEventId);
|
||||
replyEventID, editEventId, inputField.userAutocompleted);
|
||||
clearAttachment();
|
||||
currentRoom.markAllMessagesAsRead();
|
||||
clear();
|
||||
@@ -481,6 +487,10 @@ ToolBar {
|
||||
|
||||
function autoComplete() {
|
||||
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
|
||||
// Unfortunally it doesn't
|
||||
if (!autoCompleteListView.currentItem.isEmoji) {
|
||||
inputField.userAutocompleted[autoCompleteListView.currentItem.displayText] = autoCompleteListView.currentItem.userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -573,6 +583,7 @@ ToolBar {
|
||||
|
||||
function clear() {
|
||||
inputField.clear()
|
||||
inputField.userAutocompleted = {};
|
||||
}
|
||||
|
||||
function clearEditReply() {
|
||||
|
||||
Reference in New Issue
Block a user