fix(ChatColumnView): fix input `Unblock` button state (#11073)
This commit is contained in:
parent
476db57837
commit
4849230054
|
@ -93,7 +93,7 @@ method load*(self: Module, chatItem: chat_item.Item) =
|
||||||
self.controller.isUsersListAvailable(), chatName, chatImage,
|
self.controller.isUsersListAvailable(), chatName, chatImage,
|
||||||
chatItem.color, chatItem.description, chatItem.emoji, chatItem.hasUnreadMessages, chatItem.notificationsCount,
|
chatItem.color, chatItem.description, chatItem.emoji, chatItem.hasUnreadMessages, chatItem.notificationsCount,
|
||||||
chatItem.muted, chatItem.position, isUntrustworthy = trustStatus == TrustStatus.Untrustworthy,
|
chatItem.muted, chatItem.position, isUntrustworthy = trustStatus == TrustStatus.Untrustworthy,
|
||||||
isContact)
|
isContact, chatItem.blocked)
|
||||||
|
|
||||||
self.inputAreaModule.load()
|
self.inputAreaModule.load()
|
||||||
self.messagesModule.load()
|
self.messagesModule.load()
|
||||||
|
|
|
@ -35,10 +35,10 @@ QtObject:
|
||||||
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
||||||
name, icon: string, color, description, emoji: string, hasUnreadMessages: bool,
|
name, icon: string, color, description, emoji: string, hasUnreadMessages: bool,
|
||||||
notificationsCount: int, muted: bool, position: int, isUntrustworthy: bool,
|
notificationsCount: int, muted: bool, position: int, isUntrustworthy: bool,
|
||||||
isContact: bool) =
|
isContact: bool, blocked: bool) =
|
||||||
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name,
|
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name,
|
||||||
icon, color, description, emoji, hasUnreadMessages, notificationsCount, muted, position,
|
icon, color, description, emoji, hasUnreadMessages, notificationsCount, muted, position,
|
||||||
isUntrustworthy, isContact)
|
isUntrustworthy, isContact, blocked)
|
||||||
self.delegate.viewDidLoad()
|
self.delegate.viewDidLoad()
|
||||||
self.chatDetailsChanged()
|
self.chatDetailsChanged()
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ SplitView {
|
||||||
sourceComponent: StatusChatInput {
|
sourceComponent: StatusChatInput {
|
||||||
id: chatInput
|
id: chatInput
|
||||||
property var globalUtils: globalUtilsMock.globalUtils
|
property var globalUtils: globalUtilsMock.globalUtils
|
||||||
|
enabled: enabledCheckBox.checked
|
||||||
usersStore: QtObject {
|
usersStore: QtObject {
|
||||||
readonly property var usersModel: fakeUsersModel
|
readonly property var usersModel: fakeUsersModel
|
||||||
}
|
}
|
||||||
|
@ -114,14 +115,26 @@ SplitView {
|
||||||
SplitView.minimumWidth: 300
|
SplitView.minimumWidth: 300
|
||||||
SplitView.preferredWidth: 300
|
SplitView.preferredWidth: 300
|
||||||
|
|
||||||
UsersModelEditor {
|
ColumnLayout {
|
||||||
id: modelEditor
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: fakeUsersModel
|
CheckBox {
|
||||||
|
id: enabledCheckBox
|
||||||
|
text: "enabled"
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
MenuSeparator {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
UsersModelEditor {
|
||||||
|
id: modelEditor
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
model: fakeUsersModel
|
||||||
|
|
||||||
onRemoveClicked: fakeUsersModel.remove(index, 1)
|
onRemoveClicked: fakeUsersModel.remove(index, 1)
|
||||||
onRemoveAllClicked: fakeUsersModel.clear()
|
onRemoveAllClicked: fakeUsersModel.clear()
|
||||||
onAddClicked: fakeUsersModel.append(modelEditor.getNewUser(fakeUsersModel.count))
|
onAddClicked: fakeUsersModel.append(modelEditor.getNewUser(fakeUsersModel.count))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,97 +231,114 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusChatInput {
|
RowLayout {
|
||||||
id: chatInput
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.margins: Style.current.smallPadding
|
Layout.margins: Style.current.smallPadding
|
||||||
|
|
||||||
enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned &&
|
StatusChatInput {
|
||||||
root.rootStore.isUserAllowedToSendMessage
|
id: chatInput
|
||||||
|
|
||||||
store: root.rootStore
|
Layout.fillWidth: true
|
||||||
usersStore: d.activeUsersStore
|
|
||||||
|
|
||||||
textInput.placeholderText: {
|
enabled: !d.activeChatContentModule.chatDetails.blocked
|
||||||
if (d.activeChatContentModule.chatDetails.blocked)
|
&& root.rootStore.sectionDetails.joined
|
||||||
return qsTr("This user has been blocked.")
|
&& !root.rootStore.sectionDetails.amIBanned
|
||||||
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned)
|
&& root.rootStore.isUserAllowedToSendMessage
|
||||||
return qsTr("You need to join this community to send messages")
|
|
||||||
return root.rootStore.chatInputPlaceHolderText
|
|
||||||
}
|
|
||||||
|
|
||||||
emojiPopup: root.emojiPopup
|
store: root.rootStore
|
||||||
stickersPopup: root.stickersPopup
|
usersStore: d.activeUsersStore
|
||||||
isContactBlocked: d.activeChatContentModule.chatDetails.blocked
|
|
||||||
chatType: root.activeChatType
|
|
||||||
suggestions.suggestionFilter.addSystemSuggestions: chatType === Constants.chatType.communityChat
|
|
||||||
|
|
||||||
textInput.onTextChanged: {
|
textInput.placeholderText: {
|
||||||
d.activeChatContentModule.inputAreaModule.preservedProperties.text = textInput.text
|
if (d.activeChatContentModule.chatDetails.blocked)
|
||||||
}
|
return qsTr("This user has been blocked.")
|
||||||
|
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned)
|
||||||
onReplyMessageIdChanged: {
|
return qsTr("You need to join this community to send messages")
|
||||||
d.activeChatContentModule.inputAreaModule.preservedProperties.replyMessageId = replyMessageId
|
return root.rootStore.chatInputPlaceHolderText
|
||||||
}
|
|
||||||
|
|
||||||
onFileUrlsAndSourcesChanged: {
|
|
||||||
d.activeChatContentModule.inputAreaModule.preservedProperties.fileUrlsAndSourcesJson = JSON.stringify(chatInput.fileUrlsAndSources)
|
|
||||||
}
|
|
||||||
|
|
||||||
onSendTransactionCommandButtonClicked: {
|
|
||||||
if (!d.activeChatContentModule) {
|
|
||||||
console.warn("error on sending transaction command - chat content module is not set")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isEnsVerified(d.activeChatContentModule.getMyChatId())) {
|
emojiPopup: root.emojiPopup
|
||||||
Global.openPopup(cmpSendTransactionWithEns)
|
stickersPopup: root.stickersPopup
|
||||||
} else {
|
chatType: root.activeChatType
|
||||||
Global.openPopup(cmpSendTransactionNoEns)
|
suggestions.suggestionFilter.addSystemSuggestions: chatType === Constants.chatType.communityChat
|
||||||
|
|
||||||
|
textInput.onTextChanged: {
|
||||||
|
d.activeChatContentModule.inputAreaModule.preservedProperties.text = textInput.text
|
||||||
|
}
|
||||||
|
|
||||||
|
onReplyMessageIdChanged: {
|
||||||
|
d.activeChatContentModule.inputAreaModule.preservedProperties.replyMessageId = replyMessageId
|
||||||
|
}
|
||||||
|
|
||||||
|
onFileUrlsAndSourcesChanged: {
|
||||||
|
d.activeChatContentModule.inputAreaModule.preservedProperties.fileUrlsAndSourcesJson = JSON.stringify(chatInput.fileUrlsAndSources)
|
||||||
|
}
|
||||||
|
|
||||||
|
onSendTransactionCommandButtonClicked: {
|
||||||
|
if (!d.activeChatContentModule) {
|
||||||
|
console.warn("error on sending transaction command - chat content module is not set")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utils.isEnsVerified(d.activeChatContentModule.getMyChatId())) {
|
||||||
|
Global.openPopup(cmpSendTransactionWithEns)
|
||||||
|
} else {
|
||||||
|
Global.openPopup(cmpSendTransactionNoEns)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onReceiveTransactionCommandButtonClicked: {
|
||||||
|
Global.openPopup(cmpReceiveTransaction)
|
||||||
|
}
|
||||||
|
|
||||||
|
onStickerSelected: {
|
||||||
|
root.rootStore.sendSticker(d.activeChatContentModule.getMyChatId(),
|
||||||
|
hashId,
|
||||||
|
chatInput.isReply ? chatInput.replyMessageId : "",
|
||||||
|
packId,
|
||||||
|
url)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onSendMessage: {
|
||||||
|
if (!d.activeChatContentModule) {
|
||||||
|
console.debug("error on sending message - chat content module is not set")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.rootStore.sendMessage(d.activeChatContentModule.getMyChatId(),
|
||||||
|
event,
|
||||||
|
chatInput.getTextWithPublicKeys(),
|
||||||
|
chatInput.isReply? chatInput.replyMessageId : "",
|
||||||
|
chatInput.fileUrlsAndSources
|
||||||
|
))
|
||||||
|
{
|
||||||
|
Global.playSendMessageSound()
|
||||||
|
|
||||||
|
chatInput.textInput.clear();
|
||||||
|
chatInput.textInput.textFormat = TextEdit.PlainText;
|
||||||
|
chatInput.textInput.textFormat = TextEdit.RichText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUnblockChat: {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyUpPress: {
|
||||||
|
d.activeMessagesStore.setEditModeOnLastMessage(root.rootStore.userProfileInst.pubKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onReceiveTransactionCommandButtonClicked: {
|
StatusButton {
|
||||||
Global.openPopup(cmpReceiveTransaction)
|
Layout.fillHeight: true
|
||||||
}
|
Layout.maximumHeight: chatInput.implicitHeight
|
||||||
|
verticalPadding: 0
|
||||||
onStickerSelected: {
|
visible: d.activeChatContentModule.chatDetails.blocked
|
||||||
root.rootStore.sendSticker(d.activeChatContentModule.getMyChatId(),
|
text: qsTr("Unblock")
|
||||||
hashId,
|
type: StatusBaseButton.Type.Danger
|
||||||
chatInput.isReply ? chatInput.replyMessageId : "",
|
onClicked: {
|
||||||
packId,
|
d.activeChatContentModule.unblockChat()
|
||||||
url)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
onSendMessage: {
|
|
||||||
if (!d.activeChatContentModule) {
|
|
||||||
console.debug("error on sending message - chat content module is not set")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.rootStore.sendMessage(d.activeChatContentModule.getMyChatId(),
|
|
||||||
event,
|
|
||||||
chatInput.getTextWithPublicKeys(),
|
|
||||||
chatInput.isReply? chatInput.replyMessageId : "",
|
|
||||||
chatInput.fileUrlsAndSources
|
|
||||||
))
|
|
||||||
{
|
|
||||||
Global.playSendMessageSound()
|
|
||||||
|
|
||||||
chatInput.textInput.clear();
|
|
||||||
chatInput.textInput.textFormat = TextEdit.PlainText;
|
|
||||||
chatInput.textInput.textFormat = TextEdit.RichText;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onUnblockChat: {
|
|
||||||
d.activeChatContentModule.unblockChat()
|
|
||||||
}
|
|
||||||
|
|
||||||
onKeyUpPress: {
|
|
||||||
d.activeMessagesStore.setEditModeOnLastMessage(root.rootStore.userProfileInst.pubKey)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ Rectangle {
|
||||||
|
|
||||||
property bool isImage: false
|
property bool isImage: false
|
||||||
property bool isEdit: false
|
property bool isEdit: false
|
||||||
property bool isContactBlocked: false
|
|
||||||
|
|
||||||
property int messageLimit: 2000
|
property int messageLimit: 2000
|
||||||
property int messageLimitVisible: 200
|
property int messageLimitVisible: 200
|
||||||
|
@ -135,8 +134,10 @@ Rectangle {
|
||||||
// common popups are emoji, jif and stickers
|
// common popups are emoji, jif and stickers
|
||||||
// Put controlWidth as argument with default value for binding
|
// Put controlWidth as argument with default value for binding
|
||||||
function getCommonPopupRelativePosition(popup, popupParent, controlWidth = control.width) {
|
function getCommonPopupRelativePosition(popup, popupParent, controlWidth = control.width) {
|
||||||
const controlX = controlWidth - emojiPopup.width - Style.current.halfPadding
|
const popupWidth = emojiPopup ? emojiPopup.width : 0
|
||||||
const controlY = -emojiPopup.height
|
const popupHeight = emojiPopup ? emojiPopup.height : 0
|
||||||
|
const controlX = controlWidth - popupWidth - Style.current.halfPadding
|
||||||
|
const controlY = -popupHeight
|
||||||
return popupParent.mapFromItem(control, controlX, controlY)
|
return popupParent.mapFromItem(control, controlX, controlY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1094,7 +1095,6 @@ Rectangle {
|
||||||
Layout.bottomMargin: 4
|
Layout.bottomMargin: 4
|
||||||
icon.name: "chat-commands"
|
icon.name: "chat-commands"
|
||||||
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
||||||
enabled: !control.isContactBlocked
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
d.chatCommandsPopupOpen ? Global.closePopup() : Global.openPopup(chatCommandsPopup);
|
d.chatCommandsPopupOpen ? Global.closePopup() : Global.openPopup(chatCommandsPopup);
|
||||||
d.chatCommandsPopupOpen = !d.chatCommandsPopupOpen;
|
d.chatCommandsPopupOpen = !d.chatCommandsPopupOpen;
|
||||||
|
@ -1112,7 +1112,6 @@ Rectangle {
|
||||||
icon.name: "image"
|
icon.name: "image"
|
||||||
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
||||||
visible: !isEdit
|
visible: !isEdit
|
||||||
enabled: !control.isContactBlocked
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
highlighted = true
|
highlighted = true
|
||||||
const popup = imageDialogComponent.createObject(control)
|
const popup = imageDialogComponent.createObject(control)
|
||||||
|
@ -1130,7 +1129,6 @@ Rectangle {
|
||||||
implicitHeight: inputLayout.implicitHeight + inputLayout.anchors.topMargin + inputLayout.anchors.bottomMargin
|
implicitHeight: inputLayout.implicitHeight + inputLayout.anchors.topMargin + inputLayout.anchors.bottomMargin
|
||||||
implicitWidth: inputLayout.implicitWidth + inputLayout.anchors.leftMargin + inputLayout.anchors.rightMargin
|
implicitWidth: inputLayout.implicitWidth + inputLayout.anchors.leftMargin + inputLayout.anchors.rightMargin
|
||||||
|
|
||||||
enabled: !control.isContactBlocked
|
|
||||||
color: isEdit ? Theme.palette.statusChatInput.secondaryBackgroundColor : Style.current.inputBackground
|
color: isEdit ? Theme.palette.statusChatInput.secondaryBackgroundColor : Style.current.inputBackground
|
||||||
radius: 20
|
radius: 20
|
||||||
|
|
||||||
|
@ -1539,13 +1537,5 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusQ.StatusButton {
|
|
||||||
Layout.fillHeight: true
|
|
||||||
Layout.bottomMargin: 4
|
|
||||||
visible: control.isContactBlocked
|
|
||||||
text: qsTr("Unblock")
|
|
||||||
type: StatusQ.StatusBaseButton.Type.Danger
|
|
||||||
onClicked: control.unblockChat()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue