fix(@dekstop/chat): trying to unblock a contact by hitting 'Unblock' via the chat view does not do anything

Fixes #4835
This commit is contained in:
Sale Djenic 2022-02-24 13:15:02 +01:00 committed by saledjenic
parent e46f3bdad1
commit 52fb195b39
11 changed files with 44 additions and 14 deletions

View File

@ -160,6 +160,9 @@ method muteChat*(self: Controller) =
method unmuteChat*(self: Controller) = method unmuteChat*(self: Controller) =
self.chatService.unmuteChat(self.chatId) self.chatService.unmuteChat(self.chatId)
method unblockChat*(self: Controller) =
self.contactService.unblockContact(self.chatId)
method markAllMessagesRead*(self: Controller) = method markAllMessagesRead*(self: Controller) =
self.messageService.markAllMessagesRead(self.chatId) self.messageService.markAllMessagesRead(self.chatId)
@ -188,4 +191,4 @@ method getTransactionDetails*(self: Controller, message: MessageDto): (string,st
return self.messageService.getTransactionDetails(message) return self.messageService.getTransactionDetails(message)
method getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] = method getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
return self.messageService.getWalletAccounts() return self.messageService.getWalletAccounts()

View File

@ -50,6 +50,9 @@ method muteChat*(self: AccessInterface) {.base.} =
method unmuteChat*(self: AccessInterface) {.base.} = method unmuteChat*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method unblockChat*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method markAllMessagesRead*(self: AccessInterface) {.base.} = method markAllMessagesRead*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
@ -77,5 +80,5 @@ method decodeContentHash*(self: AccessInterface, hash: string): string {.base.}
method getTransactionDetails*(self: AccessInterface, message: MessageDto): (string,string) {.base.} = method getTransactionDetails*(self: AccessInterface, message: MessageDto): (string,string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method getWalletAccounts*(self: AccessInterface): seq[WalletAccountDto] = method getWalletAccounts*(self: AccessInterface): seq[WalletAccountDto] {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -238,6 +238,9 @@ method muteChat*(self: Module) =
method unmuteChat*(self: Module) = method unmuteChat*(self: Module) =
self.controller.unmuteChat() self.controller.unmuteChat()
method unblockChat*(self: Module) =
self.controller.unblockChat()
method markAllMessagesRead*(self: Module) = method markAllMessagesRead*(self: Module) =
self.controller.markAllMessagesRead() self.controller.markAllMessagesRead()

View File

@ -27,6 +27,9 @@ method muteChat*(self: AccessInterface) {.base.} =
method unmuteChat*(self: AccessInterface) {.base.} = method unmuteChat*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method unblockChat*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method markAllMessagesRead*(self: AccessInterface) {.base.} = method markAllMessagesRead*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -43,28 +43,21 @@ QtObject:
proc getInputAreaModule(self: View): QVariant {.slot.} = proc getInputAreaModule(self: View): QVariant {.slot.} =
return self.delegate.getInputAreaModule() return self.delegate.getInputAreaModule()
QtProperty[QVariant] inputAreaModule: QtProperty[QVariant] inputAreaModule:
read = getInputAreaModule read = getInputAreaModule
proc getMessagesModule(self: View): QVariant {.slot.} = proc getMessagesModule(self: View): QVariant {.slot.} =
return self.delegate.getMessagesModule() return self.delegate.getMessagesModule()
QtProperty[QVariant] messagesModule: QtProperty[QVariant] messagesModule:
read = getMessagesModule read = getMessagesModule
proc getUsersModule(self: View): QVariant {.slot.} = proc getUsersModule(self: View): QVariant {.slot.} =
return self.delegate.getUsersModule() return self.delegate.getUsersModule()
QtProperty[QVariant] usersModule: QtProperty[QVariant] usersModule:
read = getUsersModule read = getUsersModule
proc getPinnedMessagesModel(self: View): QVariant {.slot.} = proc getPinnedMessagesModel(self: View): QVariant {.slot.} =
return self.pinnedMessagesModelVariant return self.pinnedMessagesModelVariant
QtProperty[QVariant] pinnedMessagesModel: QtProperty[QVariant] pinnedMessagesModel:
read = getPinnedMessagesModel read = getPinnedMessagesModel
@ -83,6 +76,9 @@ QtObject:
proc unmuteChat*(self: View) {.slot.} = proc unmuteChat*(self: View) {.slot.} =
self.delegate.unmuteChat() self.delegate.unmuteChat()
proc unblockChat*(self: View): string {.slot.} =
self.delegate.unblockChat()
proc markAllMessagesRead*(self: View) {.slot.} = proc markAllMessagesRead*(self: View) {.slot.} =
self.delegate.markAllMessagesRead() self.delegate.markAllMessagesRead()

View File

@ -353,6 +353,7 @@ ColumnLayout {
messageStore: messageStore messageStore: messageStore
usersStore: chatContentRoot.usersStore usersStore: chatContentRoot.usersStore
stickersLoaded: chatContentRoot.stickersLoaded stickersLoaded: chatContentRoot.stickersLoaded
isChatBlocked: chatContentRoot.isBlocked
onShowReplyArea: { onShowReplyArea: {
let obj = messageStore.getMessageByIdAsJson(messageId) let obj = messageStore.getMessageByIdAsJson(messageId)
if (!obj) { if (!obj) {
@ -463,6 +464,10 @@ ColumnLayout {
chatInput.textInput.textFormat = TextEdit.RichText; chatInput.textInput.textFormat = TextEdit.RichText;
} }
} }
onUnblockChat: {
chatContentModule.unblockChat()
}
} }
} }
} }

View File

@ -28,6 +28,7 @@ Item {
property bool stickersLoaded: false property bool stickersLoaded: false
property alias chatLogView: chatLogView property alias chatLogView: chatLogView
property bool isChatBlocked: false
property var messageContextMenuInst property var messageContextMenuInst
@ -244,6 +245,7 @@ Item {
usersStore: root.usersStore usersStore: root.usersStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
isChatBlocked: root.isChatBlocked
messageContextMenu: messageContextMenuInst messageContextMenu: messageContextMenuInst
messageId: model.id messageId: model.id

View File

@ -8,6 +8,7 @@ import utils 1.0
Rectangle { Rectangle {
id: buttonsContainer id: buttonsContainer
property bool parentIsHovered: false property bool parentIsHovered: false
property bool isChatBlocked: false
property int containerMargin: 2 property int containerMargin: 2
property int contentType: 2 property int contentType: 2
property bool isCurrentUser: false property bool isCurrentUser: false
@ -24,7 +25,8 @@ Rectangle {
signal setMessageActive(string messageId, bool active) signal setMessageActive(string messageId, bool active)
signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker) signal clickMessage(bool isProfileClick, bool isSticker, bool isImage, var image, bool emojiOnly, bool hideEmojiPicker)
visible: !buttonsContainer.placeholderMsg && !buttonsContainer.activityCenterMsg && visible: !buttonsContainer.isChatBlocked &&
!buttonsContainer.placeholderMsg && !buttonsContainer.activityCenterMsg &&
(buttonsContainer.parentIsHovered || isMessageActive) (buttonsContainer.parentIsHovered || isMessageActive)
&& contentType !== Constants.messageContentType.transactionType && contentType !== Constants.messageContentType.transactionType
width: buttonRow.width + buttonsContainer.containerMargin * 2 width: buttonRow.width + buttonsContainer.containerMargin * 2

View File

@ -27,6 +27,7 @@ Rectangle {
signal receiveTransactionCommandButtonClicked() signal receiveTransactionCommandButtonClicked()
signal stickerSelected(string hashId, string packId) signal stickerSelected(string hashId, string packId)
signal sendMessage(var event) signal sendMessage(var event)
signal unblockChat()
property var usersStore property var usersStore
@ -1159,8 +1160,7 @@ Rectangle {
text: qsTr("Unblock") text: qsTr("Unblock")
type: StatusQ.StatusBaseButton.Type.Danger type: StatusQ.StatusBaseButton.Type.Danger
onClicked: function (event) { onClicked: function (event) {
// Not Refactored Yet control.unblockChat()
// RootStore.contactsModuleInst.unblockContact(RootStore.chatsModelInst.channelView.activeChannel.id)
} }
} }
} }

View File

@ -22,6 +22,7 @@ Item {
property var messageContextMenu property var messageContextMenu
property var container property var container
property int contentType property int contentType
property bool isChatBlocked: false
property int chatHorizontalPadding: Style.current.halfPadding property int chatHorizontalPadding: Style.current.halfPadding
property int chatVerticalPadding: 7 property int chatVerticalPadding: 7
@ -78,7 +79,7 @@ Item {
} }
MessageMouseArea { MessageMouseArea {
enabled: !placeholderMessage && !isImage enabled: !root.isChatBlocked && !placeholderMessage && !isImage
anchors.fill: messageContainer anchors.fill: messageContainer
acceptedButtons: activityCenterMessage ? Qt.LeftButton : Qt.RightButton acceptedButtons: activityCenterMessage ? Qt.LeftButton : Qt.RightButton
messageContextMenu: root.messageContextMenu messageContextMenu: root.messageContextMenu
@ -95,6 +96,7 @@ Item {
ChatButtonsPanel { ChatButtonsPanel {
contentType: messageContentType contentType: messageContentType
parentIsHovered: !editModeOn && isHovered parentIsHovered: !editModeOn && isHovered
isChatBlocked: root.isChatBlocked
onHoverChanged: { onHoverChanged: {
hovered && setHovered(messageId, hovered) hovered && setHovered(messageId, hovered)
} }
@ -569,6 +571,7 @@ Item {
id: messageMouseArea id: messageMouseArea
anchors.fill: stickerLoader.active ? stickerLoader : chatText anchors.fill: stickerLoader.active ? stickerLoader : chatText
z: activityCenterMessage ? chatText.z + 1 : chatText.z -1 z: activityCenterMessage ? chatText.z + 1 : chatText.z -1
enabled: !root.isChatBlocked && !placeholderMessage
messageContextMenu: root.messageContextMenu messageContextMenu: root.messageContextMenu
messageContextMenuParent: root messageContextMenuParent: root
isHovered: root.isHovered isHovered: root.isHovered
@ -710,6 +713,8 @@ Item {
isMessageActive: isMessageActive isMessageActive: isMessageActive
isCurrentUser: root.amISender isCurrentUser: root.amISender
onAddEmojiClicked: { onAddEmojiClicked: {
if(root.isChatBlocked)
return
root.addEmoji(false, false, false, null, true, false); root.addEmoji(false, false, false, null, true, false);
// Set parent, X & Y positions for the messageContextMenu // Set parent, X & Y positions for the messageContextMenu
root.messageContextMenu.parent = emojiReactionLoader root.messageContextMenu.parent = emojiReactionLoader
@ -718,6 +723,9 @@ Item {
} }
onToggleReaction: { onToggleReaction: {
if(root.isChatBlocked)
return
if(!root.messageStore) if(!root.messageStore)
{ {
console.error("reaction cannot be toggled, message store is not valid") console.error("reaction cannot be toggled, message store is not valid")

View File

@ -23,6 +23,10 @@ Column {
property var contactsStore property var contactsStore
property var messageContextMenu property var messageContextMenu
// Once we redo qml we will know all section/chat related details in each message form the parent components
// without an explicit need to fetch those details via message store/module.
property bool isChatBlocked: false
property string messageId: "" property string messageId: ""
property string responseToMessageWithId: "" property string responseToMessageWithId: ""
property string senderId: "" property string senderId: ""
@ -359,6 +363,7 @@ Column {
contactsStore: root.contactsStore contactsStore: root.contactsStore
messageContextMenu: root.messageContextMenu messageContextMenu: root.messageContextMenu
contentType: root.messageContentType contentType: root.messageContentType
isChatBlocked: root.isChatBlocked
stickersLoaded: root.stickersLoaded stickersLoaded: root.stickersLoaded
sticker: root.sticker sticker: root.sticker