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

View File

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

View File

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