fix(Chat): Reuse chat root store connections and fix chat quick actions when blocked (#10577)

Close #10570
This commit is contained in:
Mikhail Rogachev 2023-05-09 14:31:50 +04:00 committed by GitHub
parent 44891a17fd
commit 890e0aa2bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 36 deletions

View File

@ -22,24 +22,8 @@ StatusDialog {
property string messageToUnpin
property string chatId
property bool isPinActionAvaliable: true
function updatePinActionAvaliable() {
const contactDetails = chatId ? Utils.getContactDetailsAsJson(chatId, false) : null
isPinActionAvaliable = contactDetails ? contactDetails.isContact : true
}
Connections {
target: root.store.contactsStore.myContactsModel
function onItemChanged(pubKey) {
if (chatId === pubKey) {
updatePinActionAvaliable()
}
}
}
Component.onCompleted: updatePinActionAvaliable()
readonly property var contactDetails: store ? store.oneToOneChatContact : null
readonly property bool isPinActionAvaliable: contactDetails ? contactDetails.isContact : true
width: 800
height: 428

View File

@ -36,8 +36,9 @@ Item {
property int chatsCount: parentModule && parentModule.model ? parentModule.model.count : 0
property int activeChatType: parentModule && parentModule.activeItem.type
property bool stickersLoaded: false
property var contactDetails: null
property bool isUserAdded: root.contactDetails && root.contactDetails.isAdded
readonly property var contactDetails: rootStore ? rootStore.oneToOneChatContact : null
readonly property bool isUserAdded: root.contactDetails && root.contactDetails.isAdded
signal openAppSearch()
signal openStickerPackPopup(string stickerPackId)
@ -97,21 +98,6 @@ Item {
root.createChatPropertiesStore.resetProperties()
}
function updateContactDetails() {
contactDetails = activeChatType === Constants.chatType.oneToOne && Utils.getContactDetailsAsJson(root.activeChatId, false)
}
onActiveChatIdChanged: root.updateContactDetails()
Connections {
target: root.contactsStore.myContactsModel
function onItemChanged(pubKey) {
if (pubKey === root.activeChatId)
root.updateContactDetails()
}
}
EmptyChatPanel {
anchors.fill: parent
visible: root.activeChatId === "" || root.chatsCount == 0

View File

@ -41,7 +41,7 @@ StatusMenu {
property bool isRightClickOnImage: false
property bool pinnedPopup: false
property bool pinMessageAllowedForMembers: false
property bool isDebugEnabled: store.isDebugEnabled
property bool isDebugEnabled: store && store.isDebugEnabled
property bool isEmoji: false
property bool isSticker: false
property bool hideEmojiPicker: true

View File

@ -494,6 +494,7 @@ Loader {
topPadding: showHeader ? Style.current.halfPadding : 0
bottomPadding: showHeader && d.nextMessageHasHeader() ? Style.current.halfPadding : 2
disableHover: root.disableHover ||
delegate.hideQuickActions ||
(root.chatLogView && root.chatLogView.moving) ||
(root.messageContextMenu && root.messageContextMenu.opened) ||
Global.popupOpened
@ -864,6 +865,8 @@ Loader {
return false;
if (!root.messageStore)
return false;
if (delegate.hideQuickActions)
return false;
return (root.amISender || root.amIChatAdmin) &&
(messageContentType === Constants.messageContentType.messageType ||
messageContentType === Constants.messageContentType.stickerType ||