refactor(Chat): move suggestions ListModel into StatusChatInput

StatusChatInput was relying on the suggestions ListModel, even though there was
no guarantee that it would exist. This is more apparent when using the component
in different context (e.g. Timeline/Status Updates). QML will throw a reference
error in this case.
This commit is contained in:
Pascal Precht 2020-12-07 16:14:50 +01:00 committed by Pascal Precht
parent 9745205302
commit 2baf56f505
2 changed files with 9 additions and 6 deletions

View File

@ -166,18 +166,14 @@ StackLayout {
id: messageContextMenu
}
ListModel {
id: suggestions
}
Connections {
target: chatsModel
onActiveChannelChanged: {
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
suggestions.clear()
chatInput.suggestionsList.clear()
const len = chatsModel.suggestionList.rowCount()
for (let i = 0; i < len; i++) {
suggestions.append({
chatInput.suggestionsList.append({
alias: chatsModel.suggestionList.rowData(i, "alias"),
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
address: chatsModel.suggestionList.rowData(i, "address"),

View File

@ -41,6 +41,8 @@ Rectangle {
property var fileUrls: []
property alias messageSound: sendMessageSound
property alias suggestionsList: suggestions
height: {
if (extendedArea.visible) {
return messageInput.height + extendedArea.height + Style.current.bigPadding
@ -367,6 +369,11 @@ Rectangle {
messageInputField.forceActiveFocus();
}
ListModel {
id: suggestions
}
FileDialog {
id: imageDialog
//% "Please choose an image"