feat(Chat): Disable unpin action for PinnedMessagesPopup

This commit is contained in:
MishkaRogachev 2023-03-24 16:48:05 +07:00 committed by Jonathan Rainville
parent 1f54d96f5f
commit 4d4ec22ba6
6 changed files with 35 additions and 10 deletions

View File

@ -20,6 +20,26 @@ StatusDialog {
property var pinnedMessagesModel //this doesn't belong to the messageStore, it is a part of the ChatContentStore, but we didn't introduce it yet.
property string messageToPin
property string messageToUnpin
property string chatId
property bool isChatBlocked: false
function updateIsChatBlocked() {
const contactDetails = Utils.getContactDetailsAsJson(chatId, false)
isChatBlocked = contactDetails && !contactDetails.isContact
}
Connections {
target: root.store.contactsStore.myContactsModel
function onItemChanged(pubKey) {
if (chatId === pubKey) {
updateIsChatBlocked()
}
}
}
Component.onCompleted: updateIsChatBlocked()
width: 800
height: 428
@ -136,7 +156,7 @@ StatusDialog {
z: mouseArea.z + 1
width: 32
height: 32
visible: !root.messageToPin && (hovered || mouseArea.containsMouse)
visible: !root.isChatBlocked && !root.messageToPin && (hovered || mouseArea.containsMouse)
icon.name: "unpin"
tooltip.text: qsTr("Unpin")
color: hovered ? Theme.palette.primaryColor2 : Theme.palette.indirectColor1

View File

@ -101,7 +101,7 @@ ColumnLayout {
console.warn("error on open pinned messages limit reached from message context menu - chat content module is not set")
return
}
Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, messageId)
Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, messageId, chatContentModule.getMyChatId())
}
onToggleReaction: {

View File

@ -302,7 +302,7 @@ Item {
console.warn("error on open pinned messages - chat content module is not set")
return
}
Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, "")
Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, "", chatContentModule.chatDetails.id)
}
onUnmute: {
if(!chatContentModule) {

View File

@ -168,9 +168,14 @@ QtObject {
openPopup(sendContactRequestPopupComponent, popupProperties, cb)
}
function openPinnedMessagesPopup(store, messageStore, pinnedMessagesModel, messageToPin) {
openPopup(pinnedMessagesPopup, { store: store, messageStore: messageStore,
pinnedMessagesModel: pinnedMessagesModel, messageToPin: messageToPin})
function openPinnedMessagesPopup(store, messageStore, pinnedMessagesModel, messageToPin, chatId) {
openPopup(pinnedMessagesPopup, {
store: store,
messageStore: messageStore,
pinnedMessagesModel: pinnedMessagesModel,
messageToPin: messageToPin,
chatId: chatId
})
}
function openCommunityPopup(store, community, chatCommunitySectionModule) {

View File

@ -814,7 +814,7 @@ Loader {
return;
}
Global.openPinnedMessagesPopupRequested(root.rootStore, messageStore, chatContentModule.pinnedMessagesModel, root.messageId)
Global.openPinnedMessagesPopupRequested(root.rootStore, messageStore, chatContentModule.pinnedMessagesModel, root.messageId, root.messageStore.getChatId())
}
}
},

View File

@ -13,7 +13,7 @@ QtObject {
property var userProfile
property bool appIsReady: false
signal openPinnedMessagesPopupRequested(var store, var messageStore, var pinnedMessagesModel, string messageToPin)
signal openPinnedMessagesPopupRequested(var store, var messageStore, var pinnedMessagesModel, string messageToPin, string chatId)
signal openCommunityProfilePopupRequested(var store, var community, var chatCommunitySectionModule)
signal openLinkInBrowser(string link)