diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index df381bbd59..49a05ba735 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -139,6 +139,7 @@ Item { width: parent.width height: parent.height visible: model.active && !root.rootStore.openCreateChat && isActiveChannel + chatId: model.itemId chatMessagesLoader.active: model.loaderActive rootStore: root.rootStore contactsStore: root.contactsStore @@ -149,7 +150,6 @@ Item { sendTransactionWithEnsModal: cmpSendTransactionWithEns stickersLoaded: root.stickersLoaded isBlocked: model.blocked - isUserAdded: root.isUserAdded isActiveChannel: model.active onOpenStickerPackPopup: { root.openStickerPackPopup(stickerPackId) diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index 022a70fdf8..38442dc97e 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -35,6 +35,7 @@ ColumnLayout { property var rootStore property var contactsStore property bool isActiveChannel: false + property string chatId readonly property alias chatMessagesLoader: chatMessagesLoader @@ -54,16 +55,37 @@ ColumnLayout { property Component sendTransactionWithEnsModal property bool isBlocked: false - property bool isUserAdded: false property bool stickersLoaded: false + QtObject { + id: d + + property bool isUserAdded + + function updateIsUserAdded() { + isUserAdded = Qt.binding(() => {isActiveChannel; return Utils.getContactDetailsAsJson(root.chatId, false).isAdded}) + } + + Component.onCompleted: updateIsUserAdded() + } + onIsActiveChannelChanged: { if (isActiveChannel) { chatInput.forceInputActiveFocus(); } } + Connections { + target: root.contactsStore.myContactsModel + + function onItemChanged(pubKey) { + if (pubKey === root.chatId) { + d.updateIsUserAdded() + } + } + } + Loader { Layout.fillWidth: true active: root.isBlocked @@ -83,7 +105,7 @@ ColumnLayout { id: contextmenu store: root.rootStore reactionModel: root.rootStore.emojiReactionsModel - disabledForChat: chatType === Constants.chatType.oneToOne && !root.isUserAdded + disabledForChat: chatType === Constants.chatType.oneToOne && !d.isUserAdded onPinMessage: { messageStore.pinMessage(messageId) @@ -98,8 +120,7 @@ ColumnLayout { console.warn("error on open pinned messages limit reached from message context menu - chat content module is not set") return } - const chatId = chatType === Constants.chatType.oneToOne ? chatContentModule.getMyChatId() : "" - Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, messageId, chatId) + Global.openPinnedMessagesPopupRequested(rootStore, messageStore, chatContentModule.pinnedMessagesModel, messageId, root.chatId) } onToggleReaction: { @@ -149,7 +170,7 @@ ColumnLayout { stickersPopup: root.stickersPopup usersStore: root.usersStore stickersLoaded: root.stickersLoaded - isChatBlocked: root.isBlocked || (chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne && !root.isUserAdded) + isChatBlocked: root.isBlocked || (chatContentModule && chatContentModule.chatDetails.type === Constants.chatType.oneToOne && !d.isUserAdded) channelEmoji: !chatContentModule ? "" : (chatContentModule.chatDetails.emoji || "") isActiveChannel: root.isActiveChannel onShowReplyArea: { @@ -181,7 +202,7 @@ ColumnLayout { anchors.margins: Style.current.smallPadding enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned && - !(chatType === Constants.chatType.oneToOne && !root.isUserAdded) + !(chatType === Constants.chatType.oneToOne && !d.isUserAdded) store: root.rootStore usersStore: root.usersStore