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 id: messageContextMenu
} }
ListModel {
id: suggestions
}
Connections { Connections {
target: chatsModel target: chatsModel
onActiveChannelChanged: { onActiveChannelChanged: {
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason) chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
suggestions.clear() chatInput.suggestionsList.clear()
const len = chatsModel.suggestionList.rowCount() const len = chatsModel.suggestionList.rowCount()
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
suggestions.append({ chatInput.suggestionsList.append({
alias: chatsModel.suggestionList.rowData(i, "alias"), alias: chatsModel.suggestionList.rowData(i, "alias"),
ensName: chatsModel.suggestionList.rowData(i, "ensName"), ensName: chatsModel.suggestionList.rowData(i, "ensName"),
address: chatsModel.suggestionList.rowData(i, "address"), address: chatsModel.suggestionList.rowData(i, "address"),

View File

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