diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 5a490533c4..8091e636db 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -275,8 +275,9 @@ method declineRequestToJoinCommunity*(self: Controller, requestId: string) = method createCommunityChannel*( self: Controller, name: string, - description: string) = - self.communityService.createCommunityChannel(self.sectionId, name, description) + description: string, + categoryId: string) = + self.communityService.createCommunityChannel(self.sectionId, name, description, categoryId) method createCommunityCategory*(self: Controller, name: string, channels: seq[string]) = self.communityService.createCommunityCategory(self.sectionId, name, channels) diff --git a/src/app/modules/main/chat_section/controller_interface.nim b/src/app/modules/main/chat_section/controller_interface.nim index 0ab5ae28bd..f2435d12a2 100644 --- a/src/app/modules/main/chat_section/controller_interface.nim +++ b/src/app/modules/main/chat_section/controller_interface.nim @@ -123,7 +123,7 @@ method acceptRequestToJoinCommunity*(self: AccessInterface, requestId: string) { method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string) {.base.} = raise newException(ValueError, "No implementation available") -method createCommunityChannel*(self: AccessInterface, name: string, description: string) {.base.} = +method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} = raise newException(ValueError, "No implementation available") method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} = diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 245b1d01c1..4925bc37c7 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -366,15 +366,26 @@ method addNewChat*( amIChatAdmin = self.controller.getMyCommunity().admin else: amIChatAdmin = self.amIMarkedAsAdminUser(chatDto.members) - let item = initItem(chatDto.id, chatName, chatImage, isIdenticon, chatDto.color, chatDto.description, - chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, false, 0) - self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, - communityService, messageService, gifService) - self.chatContentModules[chatDto.id].load() - self.view.chatsModel().appendItem(item) - # make new added chat active one - self.setActiveItemSubItem(item.id, "") + if chatDto.categoryId == "": + let item = initItem(chatDto.id, chatName, chatImage, isIdenticon, chatDto.color, chatDto.description, + chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, false, 0) + self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, + communityService, messageService, gifService) + self.chatContentModules[chatDto.id].load() + self.view.chatsModel().appendItem(item) + # make new added chat active one + self.setActiveItemSubItem(item.id, "") + else: + let categoryItem = self.view.chatsModel().getItemById(chatDto.categoryId) + let channelItem = initSubItem(chatDto.id, chatDto.categoryId, chatDto.name, chatDto.identicon, false, chatDto.color, + chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, + false, chatDto.position) + self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, + communityService, messageService, gifService) + self.chatContentModules[chatDto.id].load() + categoryItem.appendSubItem(channelItem) + self.setActiveItemSubItem(categoryItem.id, channelItem.id) method removeCommunityChat*(self: Module, chatId: string) = if(not self.chatContentModules.contains(chatId)): @@ -559,8 +570,8 @@ method acceptRequestToJoinCommunity*(self: Module, requestId: string) = method declineRequestToJoinCommunity*(self: Module, requestId: string) = self.controller.declineRequestToJoinCommunity(requestId) -method createCommunityChannel*(self: Module, name, description: string,) = - self.controller.createCommunityChannel(name, description) +method createCommunityChannel*(self: Module, name, description, categoryId: string) = + self.controller.createCommunityChannel(name, description, categoryId) method createCommunityCategory*(self: Module, name: string, channels: seq[string]) = self.controller.createCommunityCategory(name, channels) 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 db8ed25e44..49a498c330 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 @@ -91,7 +91,7 @@ method acceptRequestToJoinCommunity*(self: AccessInterface, requestId: string) { method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string) {.base.} = raise newException(ValueError, "No implementation available") -method createCommunityChannel*(self: AccessInterface, name: string, description: string) {.base.} = +method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} = raise newException(ValueError, "No implementation available") method leaveCommunity*(self: AccessInterface) {.base.} = diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index 6ec8910c07..a95efb3947 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -188,8 +188,8 @@ QtObject: proc declineRequestToJoinCommunity*(self: View, requestId: string) {.slot.} = self.delegate.declineRequestToJoinCommunity(requestId) - proc createCommunityChannel*(self: View, name: string, description: string) {.slot.} = - self.delegate.createCommunityChannel(name, description) + proc createCommunityChannel*(self: View, name: string, description: string, categoryId: string) {.slot.} = + self.delegate.createCommunityChannel(name, description, categoryId) proc leaveCommunity*(self: View) {.slot.} = self.delegate.leaveCommunity() diff --git a/src/app_service/service/chat/dto/chat.nim b/src/app_service/service/chat/dto/chat.nim index 9f772a163d..78156daaab 100644 --- a/src/app_service/service/chat/dto/chat.nim +++ b/src/app_service/service/chat/dto/chat.nim @@ -71,7 +71,8 @@ proc `$`*(self: ChatDto): string = profile: {self.profile}, joined: {self.joined}, syncedTo: {self.syncedTo}, - syncedFrom: {self.syncedFrom} + syncedFrom: {self.syncedFrom}, + categoryId: {self.categoryId} )""" proc toChatMember(jsonObj: JsonNode): ChatMember = diff --git a/src/app_service/service/community/service.nim b/src/app_service/service/community/service.nim index acc89522df..ade6ad0da8 100644 --- a/src/app_service/service/community/service.nim +++ b/src/app_service/service/community/service.nim @@ -441,9 +441,10 @@ QtObject: self: Service, communityId: string, name: string, - description: string) = + description: string, + categoryId: string) = try: - let response = status_go.createCommunityChannel(communityId, name, description) + let response = status_go.createCommunityChannel(communityId, name, description, categoryId) if not response.error.isNil: let error = Json.decode($response.error, RpcError) diff --git a/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml b/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml index c9a76540d5..e5c85d8f5e 100644 --- a/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml @@ -14,13 +14,14 @@ StatusModal { id: popup property bool isEdit: false + property string categoryId: "" property string channelName: "" property string channelDescription: "" readonly property int maxChannelNameLength: 30 readonly property int maxChannelDescLength: 140 - signal createCommunityChannel(string chName, string chDescription) + signal createCommunityChannel(string chName, string chDescription, string chCategoryId) signal editCommunityChannel(string chName, string chDescription) signal openPinnedMessagesPopup() @@ -204,7 +205,8 @@ StatusModal { let error = ""; if (!isEdit) { popup.createCommunityChannel(Utils.filterXSS(popup.contentItem.channelName.input.text), - Utils.filterXSS(popup.contentItem.channelDescription.input.text)) + Utils.filterXSS(popup.contentItem.channelDescription.input.text), + popup.categoryId) } else { popup.editCommunityChannel(Utils.filterXSS(popup.contentItem.channelName.input.text), Utils.filterXSS(popup.contentItem.channelDescription.input.text)) diff --git a/ui/app/AppLayouts/Chat/stores/RootStore.qml b/ui/app/AppLayouts/Chat/stores/RootStore.qml index 9fc68c32b8..76ed391079 100644 --- a/ui/app/AppLayouts/Chat/stores/RootStore.qml +++ b/ui/app/AppLayouts/Chat/stores/RootStore.qml @@ -163,8 +163,8 @@ QtObject { chatCommunitySectionModule.leaveCommunity(); } - function createCommunityChannel(channelName, channelDescription) { - chatCommunitySectionModule.createCommunityChannel(channelName, channelDescription); + function createCommunityChannel(channelName, channelDescription, categoryId) { + chatCommunitySectionModule.createCommunityChannel(channelName, channelDescription, categoryId); } function editCommunityChannel(communityId, channelId, channelName, channelDescription, channelCategoryId, popupPosition) { diff --git a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml index 31a84f34fa..c0763267ee 100644 --- a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml @@ -167,10 +167,9 @@ Item { // root.store.chatsModelInst.communities.reorderCommunityCategories(chatsModel.communities.activeCommunity.id, categoryId, to); // } -// onCategoryAddButtonClicked: Global.openPopup(createChannelPopup, { -// communityId: root.store.chatsModelInst.communities.activeCommunity.id, -// categoryId: id -// }) + onCategoryAddButtonClicked: Global.openPopup(createChannelPopup, { + categoryId: id + }) popupMenu: StatusPopupMenu { StatusMenuItem { @@ -396,8 +395,8 @@ Item { id: createChannelPopup CreateChannelPopup { anchors.centerIn: parent - onCreateCommunityChannel: function (chName, chDescription) { - root.store.createCommunityChannel(chName, chDescription) + onCreateCommunityChannel: function (chName, chDescription, chCategoryId) { + root.store.createCommunityChannel(chName, chDescription, chCategoryId) } onClosed: { destroy()