From cdd06b05eb78355253d825382dd121cb7b62cce0 Mon Sep 17 00:00:00 2001 From: Patryk Osmaczko Date: Thu, 19 May 2022 22:09:55 +0200 Subject: [PATCH] feat(@desktop/group-chat): remove explicit join for groups closes: #5717 --- .../chat_content/messages/controller.nim | 6 --- .../chat_content/messages/io_interface.nim | 3 -- .../chat_content/messages/module.nim | 14 ------ .../chat_content/messages/view.nim | 6 --- .../modules/main/chat_section/controller.nim | 3 -- src/app_service/service/chat/service.nim | 8 ---- src/backend/chat.nim | 4 -- src/backend/group_chat.nim | 5 -- .../AppLayouts/Chat/stores/MessageStore.qml | 12 ----- .../views/chat/ChannelIdentifierView.qml | 48 ------------------- ui/imports/shared/views/chat/MessageView.qml | 4 -- 11 files changed, 113 deletions(-) diff --git a/src/app/modules/main/chat_section/chat_content/messages/controller.nim b/src/app/modules/main/chat_section/chat_content/messages/controller.nim index 099fd03fe1..482b5d6212 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/controller.nim @@ -253,12 +253,6 @@ proc getTransactionDetails*(self: Controller, message: MessageDto): (string,stri proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] = return self.messageService.getWalletAccounts() -proc joinGroupChat*(self: Controller) = - var communityId = "" - if (self.belongsToCommunity): - communityId = self.sectionId - self.chatService.confirmJoiningGroup(communityId, self.chatId) - proc leaveChat*(self: Controller) = self.chatService.leaveChat(self.chatId) diff --git a/src/app/modules/main/chat_section/chat_content/messages/io_interface.nim b/src/app/modules/main/chat_section/chat_content/messages/io_interface.nim index 698f4c7b0d..2e208d4582 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/io_interface.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/io_interface.nim @@ -118,9 +118,6 @@ method requestMoreMessages*(self: AccessInterface) {.base.} = method fillGaps*(self: AccessInterface, messageId: string) {.base.} = raise newException(ValueError, "No implementation available") -method joinGroupChat*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - method leaveChat*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index f539bbb738..1d84c6d2dc 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -472,23 +472,9 @@ method requestMoreMessages*(self: Module) = method fillGaps*(self: Module, messageId: string) = self.controller.fillGaps(messageId) -method joinGroupChat*(self: Module) = - self.controller.joinGroupChat() - method leaveChat*(self: Module) = self.controller.leaveChat() -method didIJoinedChat*(self: Module): bool = - let chatDto = self.controller.getChatDetails() - if(chatDto.chatType != ChatType.PrivateGroupChat): - return true - - let myPublicKey = singletonInstance.userProfile.getPubKey() - for member in chatDto.members: - if (member.id == myPublicKey): - return member.joined - return true - method onChatMemberUpdated*(self: Module, publicKey: string, admin: bool, joined: bool) = let chatDto = self.controller.getChatDetails() if(chatDto.chatType != ChatType.PrivateGroupChat): diff --git a/src/app/modules/main/chat_section/chat_content/messages/view.nim b/src/app/modules/main/chat_section/chat_content/messages/view.nim index 30e7fee2b8..8226bc60d5 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/view.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/view.nim @@ -157,15 +157,9 @@ QtObject: proc fillGaps(self: View, messageId: string) {.slot.} = self.delegate.fillGaps(messageId) - proc joinGroupChat*(self: View) {.slot.} = - self.delegate.joinGroupChat() - proc leaveChat*(self: View) {.slot.} = self.delegate.leaveChat() - proc didIJoinedChat(self: View): bool {.slot.} = - return self.delegate.didIJoinedChat() - proc refreshAMessageUserRespondedTo(self: View, msgId: string) {.signal.} proc emitRefreshAMessageUserRespondedToSignal*(self: View, msgId: string) = self.refreshAMessageUserRespondedTo(msgId) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 9f7404f380..770983b6b3 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -310,9 +310,6 @@ proc createGroupChat*(self: Controller, communityID: string, groupName: string, self.contactService, self.chatService, self.communityService, self.messageService, self.gifService, self.mailserversService) -proc confirmJoiningGroup*(self: Controller, communityID: string, chatID: string) = - self.chatService.confirmJoiningGroup(communityID, self.getActiveChatId()) - proc joinGroupChatFromInvitation*(self: Controller, groupName: string, chatId: string, adminPK: string) = let response = self.chatService.createGroupChatFromInvitation(groupName, chatId, adminPK) if(response.success): diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index 84f54af79e..9e5f9e04aa 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -502,14 +502,6 @@ QtObject: except Exception as e: error "error while making user admin: ", msg = e.msg - - proc confirmJoiningGroup*(self: Service, communityID: string, chatID: string) = - try: - let response = status_group_chat.confirmJoiningGroup(communityID, chatId) - self.emitUpdate(response) - except Exception as e: - error "error while confirmation joining to group: ", msg = e.msg - proc createGroupChatFromInvitation*(self: Service, groupName: string, chatId: string, adminPK: string): tuple[chatDto: ChatDto, success: bool] = try: let response = status_group_chat.createGroupChatFromInvitation(groupName, chatId, adminPK) diff --git a/src/backend/chat.nim b/src/backend/chat.nim index 5dd552a5da..1bb9b23428 100644 --- a/src/backend/chat.nim +++ b/src/backend/chat.nim @@ -124,10 +124,6 @@ proc createGroupChat*(communityID: string, groupName: string, pubKeys: seq[strin let payload = %* [nil, communityID, groupName, pubKeys] result = callPrivateRPC("createGroupChatWithMembers".prefix, payload) -proc confirmJoiningGroup*(communityID: string, chatId: string): RpcResponse[JsonNode] {.raises: [Exception].} = - let payload = %* [communityID, chatId] - result = callPrivateRPC("confirmJoiningGroup".prefix, payload) - proc createGroupChatFromInvitation*(groupName: string, chatId: string, adminPK: string): RpcResponse[JsonNode] {.raises: [Exception].} = let payload = %* [groupName, chatId, adminPK] result = callPrivateRPC("createGroupChatFromInvitation".prefix, payload) diff --git a/src/backend/group_chat.nim b/src/backend/group_chat.nim index e3d4d259c3..61ed23af29 100644 --- a/src/backend/group_chat.nim +++ b/src/backend/group_chat.nim @@ -39,11 +39,6 @@ proc makeAdmin*(communityID: string, chatID: string, member: string): RpcRespons return core.callPrivateRPC("chat_makeAdmin", payload) -proc confirmJoiningGroup*(communityID: string, chatID: string): RpcResponse[JsonNode] {.raises: [Exception].} = - let payload = %* [communityID, chatID] - - return core.callPrivateRPC("chat_confirmJoiningGroup", payload) - proc renameChat*(communityID: string, chatID: string, name: string): RpcResponse[JsonNode] {.raises: [Exception].} = let payload = %* [communityID, chatID, name] diff --git a/ui/app/AppLayouts/Chat/stores/MessageStore.qml b/ui/app/AppLayouts/Chat/stores/MessageStore.qml index cd0b39cadb..ef08cda20e 100644 --- a/ui/app/AppLayouts/Chat/stores/MessageStore.qml +++ b/ui/app/AppLayouts/Chat/stores/MessageStore.qml @@ -234,24 +234,12 @@ QtObject { return messageModule.fillGaps(messageId); } - function joinGroupChat() { - if(!messageModule) - return - messageModule.joinGroupChat(); - } - function leaveChat() { if(!messageModule) return messageModule.leaveChat(); } - function didIJoinedChat() { - if(!messageModule) - return true - return messageModule.didIJoinedChat(); - } - property bool playAnimation: { if(!Global.applicationWindow.active) return false diff --git a/ui/imports/shared/views/chat/ChannelIdentifierView.qml b/ui/imports/shared/views/chat/ChannelIdentifierView.qml index 13cb4e1887..e5024e85a9 100644 --- a/ui/imports/shared/views/chat/ChannelIdentifierView.qml +++ b/ui/imports/shared/views/chat/ChannelIdentifierView.qml @@ -21,10 +21,6 @@ Column { property string chatColor: "" property string chatEmoji: "" property string chatIcon: "" - property bool didIJoinedChat: true - - signal joinChatClicked() - signal rejectJoiningChatClicked() StatusSmartIdenticon { anchors.horizontalCenter: parent.horizontalCenter @@ -75,48 +71,4 @@ Column { horizontalAlignment: Text.AlignHCenter textFormat: Text.RichText } - - Item { - id: joinOrDecline - visible: root.chatType === Constants.chatType.privateGroupChat && !root.amIChatAdmin && !root.didIJoinedChat - anchors.horizontalCenter: parent.horizontalCenter - width: visible ? joinChat.width : 0 - height: visible ? 100 : 0 - - StyledText { - id: joinChat - //% "Join chat" - text: qsTrId("join-chat") - font.pixelSize: 20 - color: Style.current.blue - anchors.horizontalCenter: parent.horizontalCenter - - MouseArea { - cursorShape: Qt.PointingHandCursor - anchors.fill: parent - onClicked: { - root.joinChatClicked() - joinOrDecline.visible = false // Once we start getting member `joined` updates from `status-go` we can remove this - } - } - } - - StyledText { - //% "Decline invitation" - text: qsTrId("group-chat-decline-invitation") - font.pixelSize: 20 - color: Style.current.blue - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: joinChat.bottom - anchors.topMargin: Style.current.padding - MouseArea { - cursorShape: Qt.PointingHandCursor - anchors.fill: parent - onClicked: { - root.rejectJoiningChatClicked() - joinOrDecline.visible = false // Once we start getting member `joined` updates from `status-go` we can remove this - } - } - } - } } diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 184d34bedf..45cd13494f 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -290,10 +290,6 @@ Column { chatEmoji: root.channelEmoji amIChatAdmin: root.messageStore.amIChatAdmin() chatIcon: root.senderIcon - didIJoinedChat: root.messageStore.didIJoinedChat() - - onJoinChatClicked: root.messageStore.joinGroupChat() - onRejectJoiningChatClicked: root.messageStore.leaveChat() } }