refactor(StatusPopupMenu): expose category and chat id via open handler

Closes #192
This commit is contained in:
Pascal Precht 2021-06-25 12:26:29 +02:00 committed by Michał Cieślak
parent dbb8d941a5
commit d46130b9a5
3 changed files with 19 additions and 7 deletions

View File

@ -204,6 +204,10 @@ Rectangle {
property string chatId
openHandler: function (id) {
chatId = id
}
StatusMenuItem {
text: "View Profile"
icon.name: "group-chat"
@ -355,6 +359,10 @@ Rectangle {
property string categoryId
openHandler: function (id) {
categoryId = id
}
StatusMenuItem {
text: "Mute Category"
icon.name: "notification"

View File

@ -50,7 +50,7 @@ Column {
hasUnreadMessages: !!model.hasUnreadMessages
hasMention: !!model.hasMention
badge.value: model.unreadMessagesCount || 0
selected: model.chatId === statusChatList.selectedChatId
selected: (model.chatId || model.id) === statusChatList.selectedChatId
icon.color: model.color || ""
image.isIdenticon: !!!profileImage && !!!model.identityImage && !!model.identicon
@ -64,11 +64,8 @@ Column {
let originalCloseHandler = popupMenuSlot.item.closeHandler
popupMenuSlot.item.openHandler = function () {
if (popupMenuSlot.item.hasOwnProperty('chatId')) {
popupMenuSlot.item.chatId = model.chatId || model.id
}
if (!!originalOpenHandler) {
originalOpenHandler()
originalOpenHandler((model.chatId || model.id))
}
}

View File

@ -68,14 +68,21 @@ Column {
id: popupMenuSlot
active: !!statusChatListCategory.popupMenu
onLoaded: {
let originalOpenHandler = popupMenuSlot.item.openHandler
let originalCloseHandler = popupMenuSlot.item.closeHandler
popupMenuSlot.item.openHandler = function () {
if (popupMenuSlot.item.hasOwnProperty('categoryId')) {
popupMenuSlot.item.categoryId = statusChatListCategory.categoryId
if (!!originalOpenHandler) {
originalOpenHandler(statusChatListCategory.categoryId)
}
}
popupMenuSlot.item.closeHandler = function () {
statusChatListCategoryItem.highlighted = false
statusChatListCategoryItem.menuButton.highlighted = false
if (!!originalCloseHandler) {
originalCloseHandler()
}
}
}
}