fix(ChatColumnView): fix input `Unblock` button state (#11073)

This commit is contained in:
Igor Sirotin 2023-06-14 18:09:46 +03:00 committed by GitHub
parent 476db57837
commit 4849230054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 121 additions and 101 deletions

View File

@ -93,7 +93,7 @@ method load*(self: Module, chatItem: chat_item.Item) =
self.controller.isUsersListAvailable(), chatName, chatImage,
chatItem.color, chatItem.description, chatItem.emoji, chatItem.hasUnreadMessages, chatItem.notificationsCount,
chatItem.muted, chatItem.position, isUntrustworthy = trustStatus == TrustStatus.Untrustworthy,
isContact)
isContact, chatItem.blocked)
self.inputAreaModule.load()
self.messagesModule.load()

View File

@ -35,10 +35,10 @@ QtObject:
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
name, icon: string, color, description, emoji: string, hasUnreadMessages: bool,
notificationsCount: int, muted: bool, position: int, isUntrustworthy: bool,
isContact: bool) =
isContact: bool, blocked: bool) =
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name,
icon, color, description, emoji, hasUnreadMessages, notificationsCount, muted, position,
isUntrustworthy, isContact)
isUntrustworthy, isContact, blocked)
self.delegate.viewDidLoad()
self.chatDetailsChanged()

View File

@ -89,6 +89,7 @@ SplitView {
sourceComponent: StatusChatInput {
id: chatInput
property var globalUtils: globalUtilsMock.globalUtils
enabled: enabledCheckBox.checked
usersStore: QtObject {
readonly property var usersModel: fakeUsersModel
}
@ -114,14 +115,26 @@ SplitView {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 300
UsersModelEditor {
id: modelEditor
ColumnLayout {
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)
onRemoveAllClicked: fakeUsersModel.clear()
onAddClicked: fakeUsersModel.append(modelEditor.getNewUser(fakeUsersModel.count))
onRemoveClicked: fakeUsersModel.remove(index, 1)
onRemoveAllClicked: fakeUsersModel.clear()
onAddClicked: fakeUsersModel.append(modelEditor.getNewUser(fakeUsersModel.count))
}
}
}
}

View File

@ -231,97 +231,114 @@ Item {
}
}
StatusChatInput {
id: chatInput
RowLayout {
Layout.fillWidth: true
Layout.margins: Style.current.smallPadding
enabled: root.rootStore.sectionDetails.joined && !root.rootStore.sectionDetails.amIBanned &&
root.rootStore.isUserAllowedToSendMessage
StatusChatInput {
id: chatInput
store: root.rootStore
usersStore: d.activeUsersStore
Layout.fillWidth: true
textInput.placeholderText: {
if (d.activeChatContentModule.chatDetails.blocked)
return qsTr("This user has been blocked.")
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned)
return qsTr("You need to join this community to send messages")
return root.rootStore.chatInputPlaceHolderText
}
enabled: !d.activeChatContentModule.chatDetails.blocked
&& root.rootStore.sectionDetails.joined
&& !root.rootStore.sectionDetails.amIBanned
&& root.rootStore.isUserAllowedToSendMessage
emojiPopup: root.emojiPopup
stickersPopup: root.stickersPopup
isContactBlocked: d.activeChatContentModule.chatDetails.blocked
chatType: root.activeChatType
suggestions.suggestionFilter.addSystemSuggestions: chatType === Constants.chatType.communityChat
store: root.rootStore
usersStore: d.activeUsersStore
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
textInput.placeholderText: {
if (d.activeChatContentModule.chatDetails.blocked)
return qsTr("This user has been blocked.")
if (!root.rootStore.sectionDetails.joined || root.rootStore.sectionDetails.amIBanned)
return qsTr("You need to join this community to send messages")
return root.rootStore.chatInputPlaceHolderText
}
if (Utils.isEnsVerified(d.activeChatContentModule.getMyChatId())) {
Global.openPopup(cmpSendTransactionWithEns)
} else {
Global.openPopup(cmpSendTransactionNoEns)
emojiPopup: root.emojiPopup
stickersPopup: root.stickersPopup
chatType: root.activeChatType
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: {
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
StatusButton {
Layout.fillHeight: true
Layout.maximumHeight: chatInput.implicitHeight
verticalPadding: 0
visible: d.activeChatContentModule.chatDetails.blocked
text: qsTr("Unblock")
type: StatusBaseButton.Type.Danger
onClicked: {
d.activeChatContentModule.unblockChat()
}
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)
}
}
}

View File

@ -45,7 +45,6 @@ Rectangle {
property bool isImage: false
property bool isEdit: false
property bool isContactBlocked: false
property int messageLimit: 2000
property int messageLimitVisible: 200
@ -135,8 +134,10 @@ Rectangle {
// common popups are emoji, jif and stickers
// Put controlWidth as argument with default value for binding
function getCommonPopupRelativePosition(popup, popupParent, controlWidth = control.width) {
const controlX = controlWidth - emojiPopup.width - Style.current.halfPadding
const controlY = -emojiPopup.height
const popupWidth = emojiPopup ? emojiPopup.width : 0
const popupHeight = emojiPopup ? emojiPopup.height : 0
const controlX = controlWidth - popupWidth - Style.current.halfPadding
const controlY = -popupHeight
return popupParent.mapFromItem(control, controlX, controlY)
}
@ -1094,7 +1095,6 @@ Rectangle {
Layout.bottomMargin: 4
icon.name: "chat-commands"
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
enabled: !control.isContactBlocked
onClicked: {
d.chatCommandsPopupOpen ? Global.closePopup() : Global.openPopup(chatCommandsPopup);
d.chatCommandsPopupOpen = !d.chatCommandsPopupOpen;
@ -1112,7 +1112,6 @@ Rectangle {
icon.name: "image"
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
visible: !isEdit
enabled: !control.isContactBlocked
onClicked: {
highlighted = true
const popup = imageDialogComponent.createObject(control)
@ -1130,7 +1129,6 @@ Rectangle {
implicitHeight: inputLayout.implicitHeight + inputLayout.anchors.topMargin + inputLayout.anchors.bottomMargin
implicitWidth: inputLayout.implicitWidth + inputLayout.anchors.leftMargin + inputLayout.anchors.rightMargin
enabled: !control.isContactBlocked
color: isEdit ? Theme.palette.statusChatInput.secondaryBackgroundColor : Style.current.inputBackground
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()
}
}
}