refactor(communities): create channel in specific category

This commit is contained in:
Richard Ramos 2022-01-31 09:33:42 -04:00 committed by Sale Djenic
parent 1a255f5bcc
commit 192a0c4d19
10 changed files with 44 additions and 29 deletions

View File

@ -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)

View File

@ -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.} =

View File

@ -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)

View File

@ -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.} =

View File

@ -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()

View File

@ -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 =

View File

@ -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)

View File

@ -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))

View File

@ -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) {

View File

@ -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()