fix(@desktop/pinned): proper popup menu for pinned messages dialog

This commit is contained in:
Andrei Smirnov 2021-08-16 15:35:24 +03:00 committed by Iuri Matias
parent c5d841f68d
commit 87b3f4f2c0
3 changed files with 21 additions and 14 deletions

View File

@ -22,6 +22,7 @@ Item {
case Constants.chatTypePublic: return isCurrentUser case Constants.chatTypePublic: return isCurrentUser
case Constants.chatTypeCommunity: return chatsModel.communities.activeCommunity.admin ? true : isCurrentUser case Constants.chatTypeCommunity: return chatsModel.communities.activeCommunity.admin ? true : isCurrentUser
case Constants.chatTypeStatusUpdate: return false case Constants.chatTypeStatusUpdate: return false
default: return false
} }
property bool showEdit: true property bool showEdit: true
property var messageContextMenu property var messageContextMenu

View File

@ -13,7 +13,6 @@ import "./"
StatusPopupMenu { StatusPopupMenu {
id: messageContextMenu id: messageContextMenu
width: emojiContainer.visible ? emojiContainer.width : 176 width: emojiContainer.visible ? emojiContainer.width : 176
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
property string messageId property string messageId
property int contentType property int contentType
@ -22,7 +21,7 @@ StatusPopupMenu {
property bool emojiOnly: false property bool emojiOnly: false
property bool hideEmojiPicker: false property bool hideEmojiPicker: false
property bool pinnedMessage: false property bool pinnedMessage: false
property bool showJumpTo: false property bool pinnedPopup: false
property bool isText: false property bool isText: false
property bool isCurrentUser: false property bool isCurrentUser: false
property string linkUrls: "" property string linkUrls: ""
@ -37,11 +36,10 @@ StatusPopupMenu {
property var reactionModel property var reactionModel
property bool canPin: { property bool canPin: {
const nbPinnedMessages = chatsModel.messageView.pinnedMessagesList.count const nbPinnedMessages = chatsModel.messageView.pinnedMessagesList.count
return nbPinnedMessages < Constants.maxNumberOfPins return nbPinnedMessages < Constants.maxNumberOfPins
} }
signal closeParentPopup signal shouldCloseParentPopup
function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) { function show(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, emojiReactionsModel) {
userName = userNameParam || "" userName = userNameParam || ""
@ -282,7 +280,7 @@ StatusPopupMenu {
StatusMenuItem { StatusMenuItem {
id: deleteMessageAction id: deleteMessageAction
enabled: isCurrentUser && !isProfile && !emojiOnly && enabled: isCurrentUser && !isProfile && !emojiOnly && !pinnedPopup &&
(contentType === Constants.messageType || (contentType === Constants.messageType ||
contentType === Constants.stickerType || contentType === Constants.stickerType ||
contentType === Constants.emojiType || contentType === Constants.emojiType ||
@ -315,4 +313,15 @@ StatusPopupMenu {
icon.name: "delete" icon.name: "delete"
type: StatusMenuItem.Type.Danger type: StatusMenuItem.Type.Danger
} }
StatusMenuItem {
enabled: messageContextMenu.pinnedPopup
text: qsTr("Jump to")
onTriggered: {
positionAtMessage(messageContextMenu.messageId)
messageContextMenu.close()
messageContextMenu.shouldCloseParentPopup()
}
icon.name: "up"
}
} }

View File

@ -101,14 +101,14 @@ ModalPopup {
function closePopup() { function closePopup() {
popup.close() popup.close()
} }
delegate: Item { delegate: Item {
property var listView: ListView.view
width: parent.width width: parent.width
height: messageItem.height height: messageItem.height
Message { Message {
id: messageItem id: messageItem
property var view: ListView.view
fromAuthor: model.fromAuthor fromAuthor: model.fromAuthor
chatId: model.chatId chatId: model.chatId
userName: model.userName userName: model.userName
@ -138,14 +138,11 @@ ModalPopup {
isEdited: model.isEdited isEdited: model.isEdited
showEdit: false showEdit: false
messageContextMenu: MessageContextMenu { messageContextMenu: MessageContextMenu {
showJumpTo: true pinnedPopup: true
pinnedMessage: true pinnedMessage: true
reactionModel: EmojiReactions { } reactionModel: EmojiReactions {}
onShouldCloseParentPopup: {
onCloseParentPopup: { listView.closePopup()
if (messageItem.view) {
messageItem.view.closePopup()
}
} }
} }
} }