From 293288a0b61c59587d58c295e8d4c9969adffa80 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 28 May 2021 14:25:55 +0200 Subject: [PATCH] Fix completion when tabing users This was caused by weird bindings. Now just access the userId value directly. Fix #324 (cherry picked from commit d9125148fe034afd94625dac80a9d465d478e4ac) --- imports/NeoChat/Component/ChatBox/ChatBar.qml | 2 +- imports/NeoChat/Component/ChatBox/CompletionMenu.qml | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/imports/NeoChat/Component/ChatBox/ChatBar.qml b/imports/NeoChat/Component/ChatBox/ChatBar.qml index 0509dd4d8..05a9f2d22 100644 --- a/imports/NeoChat/Component/ChatBox/ChatBar.qml +++ b/imports/NeoChat/Component/ChatBox/ChatBar.qml @@ -371,7 +371,7 @@ ToolBar { function complete() { documentHandler.replaceAutoComplete(completionMenu.currentDisplayText); if (completionMenu.completionType === ChatDocumentHandler.User) { - userAutocompleted[completionMenu.currentDisplayText] = completionMenu.currentUserId; + userAutocompleted[completionMenu.currentDisplayText] = completionMenu.currentItem.userId; } } } diff --git a/imports/NeoChat/Component/ChatBox/CompletionMenu.qml b/imports/NeoChat/Component/ChatBox/CompletionMenu.qml index f225ba27c..92e17c935 100644 --- a/imports/NeoChat/Component/ChatBox/CompletionMenu.qml +++ b/imports/NeoChat/Component/ChatBox/CompletionMenu.qml @@ -22,8 +22,7 @@ Popup { property alias delegate: completionListView.delegate // Autocomplee text - property string currentDisplayText: currentItem && currentItem.displayName ? currentItem.displayName : "" - property string currentUserId: currentItem && currentItem.id ? currentItem.id : "" + property string currentDisplayText: currentItem && (currentItem.displayName ?? "") property int completionType: ChatDocumentHandler.Emoji property int beginPosition: 0 @@ -78,6 +77,7 @@ Popup { id: usernameItem width: ListView.view.width ?? implicitWidth property string displayName: modelData.displayName + property string userId: modelData.id leading: Kirigami.Avatar { implicitHeight: Kirigami.Units.gridUnit implicitWidth: implicitHeight @@ -86,11 +86,6 @@ Popup { } text: modelData.displayName onClicked: completeTriggered(); - Component.onCompleted: { - completionMenu.currentUserId = Qt.binding(() => { - return modelData.id ?? ""; - }); - } } }