fix(ChannelPicker): re-hook channel picker with new model and functions

Fixes #4550
This commit is contained in:
Jonathan Rainville 2022-01-24 12:59:59 -05:00 committed by Sale Djenic
parent c9e049e6d8
commit 311abcd23a
3 changed files with 21 additions and 25 deletions

View File

@ -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()
}
}
}

View File

@ -23,6 +23,9 @@ StatusInputListPopup {
getText: function (modelData) {
return modelData.shortname
}
getId: function (modelData) {
return modelData.unicode
}
onClicked: function (index) {
emojiSuggestions.addEmoji(index)
}

View File

@ -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))
}
}
}