From 311abcd23acacef314ac47978b426dcaf287d30b Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 24 Jan 2022 12:59:59 -0500 Subject: [PATCH] fix(ChannelPicker): re-hook channel picker with new model and functions Fixes #4550 --- ui/app/AppMain.qml | 18 +++++++------ .../status/StatusEmojiSuggestionPopup.qml | 3 +++ .../shared/status/StatusInputListPopup.qml | 25 ++++++------------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/ui/app/AppMain.qml b/ui/app/AppMain.qml index f3ae65a82f..892b96d397 100644 --- a/ui/app/AppMain.qml +++ b/ui/app/AppMain.qml @@ -777,11 +777,14 @@ Item { width: 350 x: parent.width / 2 - width / 2 y: parent.height / 2 - height / 2 - // Not Refactored Yet -// modelList: chatsModel.channelView.chats + // TODO improve this to work with community Chats as well + modelList: mainModule.getChatSectionModule().model getText: function (modelData) { return modelData.name } + getId: function (modelData) { + return modelData.itemId + } getImageComponent: function (parent, modelData) { return statusSmartIdenticonComponent.createObject(parent, { imageSource: modelData.identicon, @@ -789,12 +792,11 @@ Item { }); } - // Not Refactored Yet -// onClicked: function (index) { -// Global.changeAppSectionBySectionType(Constants.appSection.chat) -// chatsModel.channelView.setActiveChannelByIndex(index) -// channelPicker.close() -// } + onClicked: function (index, id) { + Global.changeAppSectionBySectionType(Constants.appSection.chat) + mainModule.getChatSectionModule().setActiveItem(id, "") + channelPicker.close() + } } } diff --git a/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml b/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml index 57bfac6477..807fc3e390 100644 --- a/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml +++ b/ui/imports/shared/status/StatusEmojiSuggestionPopup.qml @@ -23,6 +23,9 @@ StatusInputListPopup { getText: function (modelData) { return modelData.shortname } + getId: function (modelData) { + return modelData.unicode + } onClicked: function (index) { emojiSuggestions.addEmoji(index) } diff --git a/ui/imports/shared/status/StatusInputListPopup.qml b/ui/imports/shared/status/StatusInputListPopup.qml index f3463a3e37..604f2f4b70 100644 --- a/ui/imports/shared/status/StatusInputListPopup.qml +++ b/ui/imports/shared/status/StatusInputListPopup.qml @@ -15,7 +15,8 @@ Popup { property var getImageSource property var getImageComponent property var getText: function () {} - property var onClicked: function () {} + property var getId: function () {} + signal clicked(int index, string id) property int imageWidth: 22 property int imageHeight: 22 property string title @@ -119,7 +120,7 @@ Popup { return popup.close() } if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { - return popup.onClicked(listView.currentIndex) + return popup.clicked(listView.currentIndex, popup.getId(listView.currentItem.myData)) } if (!listView.currentItem.visible) { goToNextAvailableIndex(false) @@ -139,12 +140,8 @@ Popup { clip: true delegate: Rectangle { - property string myText: { - if (typeof modelData === "undefined") { - return popup.getText(model) - } - return popup.getText(modelData) - } + property variant myData: typeof modelData === "undefined" ? model : modelData + property string myText: popup.getText(myData) id: rectangle visible: searchBox.text === "" || myText.includes(searchBox.text) color: listView.currentIndex === index ? Style.current.backgroundHover : Style.current.transparent @@ -172,10 +169,7 @@ Popup { if (!popup.getImageComponent) { return "" } - if (typeof modelData === "undefined") { - return popup.getImageComponent(imageComponentContainer, model) - } - return popup.getImageComponent(imageComponentContainer, modelData) + return popup.getImageComponent(imageComponentContainer, myData) } } } @@ -190,10 +184,7 @@ Popup { if (!popup.getImageSource) { return "" } - if (typeof modelData === "undefined") { - return popup.getImageSource(model) - } - return popup.getImageSource(modelData) + return popup.getImageSource(myData) } } } @@ -215,7 +206,7 @@ Popup { listView.currentIndex = index } onClicked: { - popup.onClicked(index) + popup.clicked(index, popup.getId(myData)) } } }