From a8f2a3cb08934ab40b476f7047c9e36cda17493c Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 25 Jan 2022 13:09:27 +0100 Subject: [PATCH] fix(@chat): react to on left chat fixes #4528 --- src/app/modules/main/chat_section/controller.nim | 12 ++++-------- .../main/chat_section/controller_interface.nim | 2 +- src/app/modules/main/chat_section/module.nim | 6 +++--- .../module_controller_delegate_interface.nim | 2 +- .../module_view_delegate_interface.nim | 2 +- src/app/modules/main/chat_section/view.nim | 4 ++-- ui/app/AppLayouts/Chat/stores/RootStore.qml | 4 ++-- ui/app/AppLayouts/Chat/views/ChatContentView.qml | 2 +- ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml | 4 ++-- ui/app/AppLayouts/Chat/views/CommunityColumnView.qml | 2 +- ui/app/AppLayouts/Chat/views/ContactsColumnView.qml | 2 +- 11 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 10202b51c4..ba98c74524 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -71,7 +71,7 @@ method init*(self: Controller) = self.events.on(chat_service.SIGNAL_CHAT_LEFT) do(e: Args): let args = chat_service.ChatArgs(e) - self.delegate.removeChat(args.chatId) + self.delegate.onCommunityChannelDeletedOrChatLeft(args.chatId) self.events.on(SIGNAL_CONTACT_ADDED) do(e: Args): var args = ContactArgs(e) @@ -105,7 +105,7 @@ method init*(self: Controller) = self.events.on(SIGNAL_COMMUNITY_CHANNEL_DELETED) do(e:Args): let args = CommunityChatIdArgs(e) if (args.communityId == self.sectionId): - self.delegate.onCommunityChannelDeleted(args.chatId) + self.delegate.onCommunityChannelDeletedOrChatLeft(args.chatId) self.events.on(SIGNAL_COMMUNITY_CHANNEL_EDITED) do(e:Args): let args = CommunityChatArgs(e) @@ -171,12 +171,8 @@ method setActiveItemSubItem*(self: Controller, itemId: string, subItemId: string self.delegate.activeItemSubItemSet(self.activeItemId, self.activeSubItemId) -method removeChat*(self: Controller, itemId: string) = - if self.isCommunitySection: - self.communityService.deleteCommunityChat(self.getMySectionId(), itemId) - # else: - # not implemented - # self.chatService.deleteChatById(itemId) +method removeCommunityChat*(self: Controller, itemId: string) = + self.communityService.deleteCommunityChat(self.getMySectionId(), itemId) method getOneToOneChatNameAndImage*(self: Controller, chatId: string): tuple[name: string, image: string, isIdenticon: bool] = diff --git a/src/app/modules/main/chat_section/controller_interface.nim b/src/app/modules/main/chat_section/controller_interface.nim index 6b0f23dde7..780fb7b364 100644 --- a/src/app/modules/main/chat_section/controller_interface.nim +++ b/src/app/modules/main/chat_section/controller_interface.nim @@ -42,7 +42,7 @@ method getChatDetailsForChatTypes*(self: AccessInterface, types: seq[ChatType]): method setActiveItemSubItem*(self: AccessInterface, itemId: string, subItemId: string) {.base.} = raise newException(ValueError, "No implementation available") -method removeChat*(self: AccessInterface, itemId: string) {.base.} = +method removeCommunityChat*(self: AccessInterface, itemId: string) {.base.} = raise newException(ValueError, "No implementation available") method getOneToOneChatNameAndImage*(self: AccessInterface, chatId: string): diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 694f9ae18f..987b388934 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -356,13 +356,13 @@ method addNewChat*( # make new added chat active one self.setActiveItemSubItem(item.id, "") -method removeChat*(self: Module, chatId: string) = +method removeCommunityChat*(self: Module, chatId: string) = if(not self.chatContentModules.contains(chatId)): return - self.controller.removeChat(chatId) + self.controller.removeCommunityChat(chatId) -method onCommunityChannelDeleted*(self: Module, chatId: string) = +method onCommunityChannelDeletedOrChatLeft*(self: Module, chatId: string) = if(not self.chatContentModules.contains(chatId)): return self.view.chatsModel().removeItemById(chatId) diff --git a/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim index 2d5ad887d7..f64c3df964 100644 --- a/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim @@ -32,7 +32,7 @@ method onContactBlocked*(self: AccessInterface, publicKey: string) {.base.} = method onContactDetailsUpdated*(self: AccessInterface, contactId: string) {.base.} = raise newException(ValueError, "No implementation available") -method onCommunityChannelDeleted*(self: AccessInterface, chatId: string) {.base.} = +method onCommunityChannelDeletedOrChatLeft*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") method onChatRenamed*(self: AccessInterface, chatId: string, newName: string) {.base.} = diff --git a/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim index 90d5cfe63f..53caf33b77 100644 --- a/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim +++ b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim @@ -21,7 +21,7 @@ method createOneToOneChat*(self: AccessInterface, chatId: string, ensName: strin method leaveChat*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") -method removeChat*(self: AccessInterface, chatId: string) {.base.} = +method removeCommunityChat*(self: AccessInterface, chatId: string) {.base.} = raise newException(ValueError, "No implementation available") method getActiveChatId*(self: AccessInterface): string {.base.} = diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index cb4ba00929..1c2d46c18f 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -157,8 +157,8 @@ QtObject: proc blockContact*(self: View, publicKey: string) {.slot.} = self.delegate.blockContact(publicKey) - proc removeChat*(self: View, chatId: string) {.slot} = - self.delegate.removeChat(chatId) + proc removeCommunityChat*(self: View, chatId: string) {.slot} = + self.delegate.removeCommunityChat(chatId) proc addGroupMembers*(self: View, chatId: string, pubKeys: string) {.slot.} = self.delegate.addGroupMembers(chatId, pubKeys) diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 243e525274..ee80bffcc4 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -193,7 +193,7 @@ QtObject { return globalUtils.plainText(text) } - function removeChat(chatId) { - chatCommunitySectionModule.removeChat(chatId) + function removeCommunityChat(chatId) { + chatCommunitySectionModule.removeCommunityChat(chatId) } } diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index a782c57351..5266988a3b 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -202,7 +202,7 @@ ColumnLayout { chatContentModule.leaveChat() } - onDeleteChat: root.rootStore.removeChat(chatId) + onDeleteCommunityChat: root.rootStore.removeCommunityChat(chatId) onDownloadMessages: { // Not Refactored Yet diff --git a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml index 47e5092c13..e72a68a8ce 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml @@ -31,7 +31,7 @@ StatusPopupMenu { signal markAllMessagesRead(string chatId) signal clearChatHistory(string chatId) signal downloadMessages(string file) - signal deleteChat(string chatId) + signal deleteCommunityChat(string chatId) signal leaveChat(string chatId) signal openPinnedMessagesList(string chatId) @@ -222,7 +222,7 @@ StatusPopupMenu { } onConfirmButtonClicked: { if(root.isCommunityChat) - root.deleteChat(root.chatId) + root.deleteCommunityChat(root.chatId) else root.leaveChat(root.chatId) diff --git a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml index 46160a4a38..bca2be884f 100644 --- a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml @@ -302,7 +302,7 @@ Item { root.communitySectionModule.leaveChat(chatId) } - onDeleteChat: root.store.removeChat(chatId) + onDeleteCommunityChat: root.store.removeCommunityChat(chatId) onDownloadMessages: { // Not Refactored Yet diff --git a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml index e1d0507b34..350f5bbcae 100644 --- a/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ContactsColumnView.qml @@ -281,7 +281,7 @@ Item { root.chatSectionModule.leaveChat(chatId) } - onDeleteChat: { + onDeleteCommunityChat: { // Not Refactored Yet }