2021-05-25 19:34:46 +00:00
|
|
|
import QtQuick 2.13
|
2021-07-26 17:27:09 +00:00
|
|
|
import QtQuick.Controls 2.3
|
2021-05-25 19:34:46 +00:00
|
|
|
import "../../../../imports"
|
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../shared/status"
|
2021-07-22 07:47:15 +00:00
|
|
|
import "../data"
|
2021-05-25 19:34:46 +00:00
|
|
|
import "../ChatColumn"
|
|
|
|
|
|
|
|
ModalPopup {
|
2021-07-26 17:27:09 +00:00
|
|
|
property bool userCanPin: {
|
|
|
|
switch (chatsModel.channelView.activeChannel.chatType) {
|
|
|
|
case Constants.chatTypePublic: return false
|
|
|
|
case Constants.chatTypeStatusUpdate: return false
|
|
|
|
case Constants.chatTypeOneToOne: return true
|
|
|
|
case Constants.chatTypePrivateGroupChat: return chatsModel.channelView.activeChannel.isAdmin(profileModel.profile.pubKey)
|
|
|
|
case Constants.chatTypeCommunity: return chatsModel.communities.activeCommunity.admin
|
|
|
|
default: return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
property string messageToPin
|
|
|
|
property string messageToUnpin
|
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
id: popup
|
|
|
|
|
|
|
|
header: Item {
|
|
|
|
height: childrenRect.height
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: title
|
2021-07-26 17:27:09 +00:00
|
|
|
text: !!messageToPin ? qsTr("Pin limit reached") :
|
|
|
|
//% "Pinned messages"
|
|
|
|
qsTrId("pinned-messages")
|
2021-05-25 19:34:46 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 17
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
2021-05-25 19:38:18 +00:00
|
|
|
property int nbMessages: pinnedMessageListView.count
|
|
|
|
|
2021-05-25 19:34:46 +00:00
|
|
|
id: nbPinnedMessages
|
2021-07-26 17:27:09 +00:00
|
|
|
text: {
|
|
|
|
if (!!messageToPin) {
|
|
|
|
return qsTr("Unpin a previous message first")
|
|
|
|
}
|
|
|
|
|
|
|
|
//% "%1 messages"
|
|
|
|
return nbMessages > 1 ? qsTrId("-1-messages").arg(nbMessages) :
|
|
|
|
//% "%1 message"
|
|
|
|
qsTrId("-1-message").arg(nbMessages)
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: title.bottom
|
|
|
|
anchors.topMargin: 2
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
anchors.top: nbPinnedMessages.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
Item {
|
|
|
|
anchors.fill: parent
|
2021-05-25 19:34:46 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
StyledText {
|
|
|
|
visible: pinnedMessageListView.count === 0
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Pinned messages will appear here."
|
|
|
|
text: qsTrId("pinned-messages-will-appear-here-")
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
ButtonGroup {
|
|
|
|
id: pinButtonGroup
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
ListView {
|
|
|
|
id: pinnedMessageListView
|
2021-06-21 19:35:32 +00:00
|
|
|
model: chatsModel.messageView.pinnedMessagesList
|
2021-05-25 19:38:18 +00:00
|
|
|
height: parent.height
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: -Style.current.padding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: -Style.current.padding
|
|
|
|
topMargin: Style.current.halfPadding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: -Style.current.halfPadding
|
|
|
|
clip: true
|
|
|
|
|
2021-07-22 07:47:15 +00:00
|
|
|
function closePopup() {
|
|
|
|
popup.close()
|
|
|
|
}
|
2021-07-26 17:27:09 +00:00
|
|
|
delegate: Item {
|
|
|
|
width: parent.width
|
|
|
|
height: messageItem.height
|
|
|
|
|
|
|
|
Message {
|
|
|
|
id: messageItem
|
|
|
|
property var view: ListView.view
|
2021-07-22 07:47:15 +00:00
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
fromAuthor: model.fromAuthor
|
|
|
|
chatId: model.chatId
|
|
|
|
userName: model.userName
|
|
|
|
alias: model.alias
|
|
|
|
localName: model.localName
|
|
|
|
message: model.message
|
|
|
|
plainText: model.plainText
|
|
|
|
identicon: model.identicon
|
|
|
|
isCurrentUser: model.isCurrentUser
|
|
|
|
timestamp: model.timestamp
|
|
|
|
sticker: model.sticker
|
|
|
|
contentType: model.contentType
|
|
|
|
outgoingStatus: model.outgoingStatus
|
|
|
|
responseTo: model.responseTo
|
|
|
|
imageClick: imagePopup.openPopup.bind(imagePopup)
|
|
|
|
messageId: model.messageId
|
|
|
|
emojiReactions: model.emojiReactions
|
|
|
|
linkUrls: model.linkUrls
|
|
|
|
communityId: model.communityId
|
|
|
|
hasMention: model.hasMention
|
|
|
|
stickerPackId: model.stickerPackId
|
|
|
|
timeout: model.timeout
|
2021-07-22 07:47:15 +00:00
|
|
|
pinnedMessage: true
|
2021-07-26 17:27:09 +00:00
|
|
|
pinnedBy: model.pinnedBy
|
|
|
|
forceHoverHandler: !messageToPin
|
|
|
|
activityCenterMessage: false
|
|
|
|
isEdited: model.isEdited
|
|
|
|
showEdit: false
|
|
|
|
messageContextMenu: MessageContextMenu {
|
|
|
|
showJumpTo: true
|
|
|
|
pinnedMessage: true
|
|
|
|
reactionModel: EmojiReactions { }
|
2021-07-22 07:47:15 +00:00
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
onCloseParentPopup: {
|
|
|
|
messageItem.view.closePopup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: !!messageToPin
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
z: 55
|
|
|
|
onClicked: radio.toggle()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusRadioButton {
|
|
|
|
id: radio
|
|
|
|
visible: !!messageToPin
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 18
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
ButtonGroup.group: pinButtonGroup
|
|
|
|
function toggle() {
|
|
|
|
radio.checked = !radio.checked
|
|
|
|
if (radio.checked) {
|
|
|
|
messageToUnpin = model.messageId
|
|
|
|
}
|
2021-07-22 07:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:38:18 +00:00
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
|
2021-07-26 17:27:09 +00:00
|
|
|
footer: Item {
|
|
|
|
width: parent.width
|
|
|
|
height: btnBack.height
|
|
|
|
|
|
|
|
StatusRoundButton {
|
|
|
|
id: btnBack
|
|
|
|
anchors.left: parent.left
|
|
|
|
icon.name: "arrow-right"
|
|
|
|
icon.width: 20
|
|
|
|
icon.height: 16
|
|
|
|
rotation: 180
|
|
|
|
onClicked: popup.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: btnUnpin
|
|
|
|
visible: !!messageToPin
|
|
|
|
enabled: !!messageToUnpin
|
|
|
|
text: qsTr("Unpin")
|
|
|
|
type: "warn"
|
|
|
|
anchors.right: parent.right
|
|
|
|
onClicked: {
|
|
|
|
const chatId = chatsModel.channelView.activeChannel.id
|
|
|
|
chatsModel.messageView.unPinMessage(messageToUnpin, chatId)
|
|
|
|
chatsModel.messageView.pinMessage(messageToPin, chatId)
|
|
|
|
messageToUnpin = messageToPin = ""
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
2021-05-25 19:34:46 +00:00
|
|
|
}
|
|
|
|
}
|