diff --git a/src/app/modules/main/chat_section/base_item.nim b/src/app/modules/main/chat_section/base_item.nim index e9a76c401c..07d0c14e3b 100644 --- a/src/app/modules/main/chat_section/base_item.nim +++ b/src/app/modules/main/chat_section/base_item.nim @@ -13,9 +13,11 @@ type muted: bool active: bool position: int + categoryId: string -proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int, - amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int) = +proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, description: string, + `type`: int, amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, + position: int, categoryId: string = "") = self.id = id self.name = name self.amIChatAdmin = amIChatAdmin @@ -29,12 +31,14 @@ proc setup*(self: BaseItem, id, name, icon: string, isIdenticon: bool, color, de self.muted = muted self.active = active self.position = position + self.categoryId = categoryId proc initBaseItem*(id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int, - amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int): BaseItem = + amIChatAdmin: bool, hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, + position: int, categoryId: string = ""): BaseItem = result = BaseItem() result.setup(id, name, icon, isIdenticon, color, description, `type`, amIChatAdmin, hasUnreadMessages, - notificationsCount, muted, active, position) + notificationsCount, muted, active, position, categoryId) proc delete*(self: BaseItem) = discard @@ -104,3 +108,9 @@ method position*(self: BaseItem): int {.inline base.} = method `position=`*(self: var BaseItem, value: int) {.inline base.} = self.position = value + +method categoryId*(self: BaseItem): string {.inline base.} = + self.categoryId + +method `categoryId=`*(self: var BaseItem, value: string) {.inline base.} = + self.categoryId = value diff --git a/src/app/modules/main/chat_section/chat_content/chat_details.nim b/src/app/modules/main/chat_section/chat_content/chat_details.nim index 7163162f31..080514cb08 100644 --- a/src/app/modules/main/chat_section/chat_content/chat_details.nim +++ b/src/app/modules/main/chat_section/chat_content/chat_details.nim @@ -16,6 +16,7 @@ QtObject: hasUnreadMessages: bool notificationsCount: int muted: bool + position: int proc delete*(self: ChatDetails) = self.QObject.delete @@ -25,8 +26,8 @@ QtObject: result.QObject.setup proc setChatDetails*(self: ChatDetails, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool, - name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool, notificationsCount: int, - muted: bool) = + name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool, + notificationsCount: int, muted: bool, position: int) = self.id = id self.`type` = `type` self.belongsToCommunity = belongsToCommunity @@ -39,6 +40,7 @@ QtObject: self.hasUnreadMessages = hasUnreadMessages self.notificationsCount = notificationsCount self.muted = muted + self.position = position proc getId(self: ChatDetails): string {.slot.} = return self.id @@ -142,4 +144,15 @@ QtObject: proc setMuted*(self: ChatDetails, value: bool) = # this is not a slot self.muted = value - self.mutedChanged() \ No newline at end of file + self.mutedChanged() + + proc positionChanged(self: ChatDetails) {.signal.} + proc getPosition(self: ChatDetails): int {.slot.} = + return self.position + QtProperty[int] position: + read = getPosition + notify = positionChanged + + proc setPotion*(self: ChatDetails, value: int) = # this is not a slot + self.position = value + self.positionChanged() \ No newline at end of file diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 0a17c7bc49..54f8f522b4 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -75,8 +75,9 @@ method load*(self: Module) = (chatName, chatImage, isIdenticon) = self.controller.getOneToOneChatNameAndImage() self.view.load(chatDto.id, chatDto.chatType.int, self.controller.belongsToCommunity(), - self.controller.isUsersListAvailable(), chatName, chatImage, isIdenticon, chatDto.color, chatDto.description, - hasNotification, notificationsCount, chatDto.muted) + self.controller.isUsersListAvailable(), chatName, chatImage, isIdenticon, + chatDto.color, chatDto.description, hasNotification, notificationsCount, + chatDto.muted, chatDto.position) self.inputAreaModule.load() self.messagesModule.load() diff --git a/src/app/modules/main/chat_section/chat_content/view.nim b/src/app/modules/main/chat_section/chat_content/view.nim index 1460341429..965918a065 100644 --- a/src/app/modules/main/chat_section/chat_content/view.nim +++ b/src/app/modules/main/chat_section/chat_content/view.nim @@ -30,10 +30,11 @@ QtObject: result.chatDetails = newChatDetails() result.chatDetailsVariant = newQVariant(result.chatDetails) - proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool, name, icon: string, - isIdenticon: bool, color, description: string, hasUnreadMessages: bool, notificationsCount: int, muted: bool) = - self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon, isIdenticon, - color, description, hasUnreadMessages, notificationsCount, muted) + proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool, + name, icon: string, isIdenticon: bool, color, description: string, hasUnreadMessages: bool, + notificationsCount: int, muted: bool, position: int) = + self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon, + isIdenticon, color, description, hasUnreadMessages, notificationsCount, muted, position) self.delegate.viewDidLoad() self.chatDetailsChanged() diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 8091e636db..4d7df1267c 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -279,6 +279,21 @@ method createCommunityChannel*( categoryId: string) = self.communityService.createCommunityChannel(self.sectionId, name, description, categoryId) +method editCommunityChannel*( + self: Controller, + channelId: string, + name: string, + description: string, + categoryId: string, + position: int) = + self.communityService.editCommunityChannel( + self.sectionId, + channelId, + name, + description, + categoryId, + position) + 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 f2435d12a2..51faa4e06d 100644 --- a/src/app/modules/main/chat_section/controller_interface.nim +++ b/src/app/modules/main/chat_section/controller_interface.nim @@ -126,6 +126,9 @@ method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string) method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} = raise newException(ValueError, "No implementation available") +method editCommunityChannel*(self: AccessInterface, channelId: string, name: string, description: string, categoryId: string, position: int) {.base.} = + raise newException(ValueError, "No implementation available") + method createCommunityCategory*(self: AccessInterface, name: string, channels: seq[string]) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/item.nim b/src/app/modules/main/chat_section/item.nim index f15459ac96..4538b9ee0b 100644 --- a/src/app/modules/main/chat_section/item.nim +++ b/src/app/modules/main/chat_section/item.nim @@ -6,10 +6,10 @@ type subItems: SubModel proc initItem*(id, name, icon: string, isIdenticon: bool, color, description: string, `type`: int, amIChatAdmin: bool, - hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int): Item = + hasUnreadMessages: bool, notificationsCount: int, muted, active: bool, position: int, categoryId: string): Item = result = Item() result.setup(id, name, icon, isIdenticon, color, description, `type`, amIChatAdmin, hasUnreadMessages, - notificationsCount, muted, active, position) + notificationsCount, muted, active, position, categoryId) result.subItems = newSubModel() proc delete*(self: Item) = @@ -34,6 +34,7 @@ proc `$`*(self: Item): string = muted: {self.muted}, active: {self.active}, position: {self.position}, + categoryId: {self.categoryId}, subItems:[ {$self.subItems} ]""" @@ -52,7 +53,8 @@ proc toJsonNode*(self: Item): JsonNode = "notificationsCount": self.notificationsCount, "muted": self.muted, "active": self.active, - "position": self.position + "position": self.position, + "categoryId": self.categoryId } proc appendSubItems*(self: Item, items: seq[SubItem]) = diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 4925bc37c7..334e020daa 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -111,7 +111,7 @@ proc buildChatUI(self: Module, events: EventEmitter, let amIChatAdmin = self.amIMarkedAsAdminUser(c.members) let item = initItem(c.id, chatName, chatImage, isIdenticon, c.color, c.description, c.chatType.int, amIChatAdmin, - hasNotification, notificationsCount, c.muted, false, 0) + hasNotification, notificationsCount, c.muted, active = false, c.position, c.categoryId) self.view.chatsModel().appendItem(item) self.addSubmodule(c.id, false, isUsersListAvailable, events, settingsService, contactService, chatService, communityService, messageService, gifService) @@ -144,8 +144,9 @@ proc buildCommunityUI(self: Module, events: EventEmitter, let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0 let notificationsCount = chatDto.unviewedMentionsCount let amIChatAdmin = comm.admin - let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color, chatDto.description, - chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, false, c.position) + let channelItem = initItem(chatDto.id, chatDto.name, chatDto.identicon, false, chatDto.color, + chatDto.description, chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, + chatDto.muted, active = false, c.position, c.categoryId) self.view.chatsModel().appendItem(channelItem) self.addSubmodule(chatDto.id, true, true, events, settingsService, contactService, chatService, communityService, messageService, gifService) @@ -187,7 +188,7 @@ proc buildCommunityUI(self: Module, events: EventEmitter, selectedSubItemId = channelItem.id var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, false, - hasNotificationPerCategory, notificationsCountPerCategory, false, false, cat.position) + hasNotificationPerCategory, notificationsCountPerCategory, false, false, cat.position, cat.id) categoryItem.prependSubItems(categoryChannels) self.view.chatsModel().appendItem(categoryItem) @@ -369,7 +370,8 @@ method addNewChat*( 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) + chatDto.chatType.int, amIChatAdmin, hasNotification, notificationsCount, chatDto.muted, + active = false, position = 0, chatDto.categoryId) self.addSubmodule(chatDto.id, belongsToCommunity, isUsersListAvailable, events, settingsService, contactService, chatService, communityService, messageService, gifService) self.chatContentModules[chatDto.id].load() @@ -395,7 +397,7 @@ method removeCommunityChat*(self: Module, chatId: string) = method onCommunityCategoryCreated*(self: Module, cat: Category, chats: seq[ChatDto]) = var categoryItem = initItem(cat.id, cat.name, "", false, "", "", ChatType.Unknown.int, false, - false, 0, false, false, cat.position) + false, 0, false, false, cat.position, cat.id) var categoryChannels: seq[SubItem] for chatDto in chats: let hasNotification = chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0 @@ -573,6 +575,10 @@ method declineRequestToJoinCommunity*(self: Module, requestId: string) = method createCommunityChannel*(self: Module, name, description, categoryId: string) = self.controller.createCommunityChannel(name, description, categoryId) +method editCommunityChannel*(self: Module, channelId, name, description, categoryId: string, + position: int) = + self.controller.editCommunityChannel(channelId, name, description, categoryId, position) + 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 49a498c330..522299dc9b 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 @@ -94,6 +94,9 @@ method declineRequestToJoinCommunity*(self: AccessInterface, requestId: string) method createCommunityChannel*(self: AccessInterface, name: string, description: string, categoryId: string) {.base.} = raise newException(ValueError, "No implementation available") +method editCommunityChannel*(self: AccessInterface, channelId, name, description, categoryId: string, position: int) {.base.} = + raise newException(ValueError, "No implementation available") + method leaveCommunity*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index a95efb3947..239bc70f13 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -191,6 +191,22 @@ QtObject: proc createCommunityChannel*(self: View, name: string, description: string, categoryId: string) {.slot.} = self.delegate.createCommunityChannel(name, description, categoryId) + proc editCommunityChannel*( + self: View, + channelId: string, + name: string, + description: string, + categoryId: string, + position: int + ) {.slot.} = + self.delegate.editCommunityChannel( + channelId, + name, + description, + categoryId, + position + ) + proc leaveCommunity*(self: View) {.slot.} = self.delegate.leaveCommunity() diff --git a/src/app/modules/main/communities/controller.nim b/src/app/modules/main/communities/controller.nim index 1c01ab2469..69c46723e2 100644 --- a/src/app/modules/main/communities/controller.nim +++ b/src/app/modules/main/communities/controller.nim @@ -68,22 +68,6 @@ method createCommunity*( imageUrl, aX, aY, bX, bY) -method editCommunityChannel*( - self: Controller, - communityId: string, - channelId: string, - name: string, - description: string, - categoryId: string, - position: int) = - self.communityService.editCommunityChannel( - communityId, - channelId, - name, - description, - categoryId, - position) - method reorderCommunityChat*( self: Controller, communityId: string, diff --git a/src/app/modules/main/communities/module.nim b/src/app/modules/main/communities/module.nim index 6f3c54d6b1..a85097aa78 100644 --- a/src/app/modules/main/communities/module.nim +++ b/src/app/modules/main/communities/module.nim @@ -108,14 +108,6 @@ method communityLeft*(self: Module, communityId: string) = # TODO to model or view discard -method communityChannelCreated*(self: Module) = - # TODO to model or view - discard - -method communityChannelEdited*(self: Module) = - # TODO to model or view - discard - method communityChannelReordered*(self: Module) = # TODO to model or view discard diff --git a/src/app/modules/main/communities/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/communities/private_interfaces/module_controller_delegate_interface.nim index eb7b150b5b..46a441949d 100644 --- a/src/app/modules/main/communities/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/communities/private_interfaces/module_controller_delegate_interface.nim @@ -5,12 +5,6 @@ method myRequestAdded*(self: AccessInterface) {.base.} = method communityLeft*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") -method communityChannelCreated*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - -method communityChannelEdited*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - method communityChannelReordered*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml b/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml index e5c85d8f5e..91505a07e5 100644 --- a/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml +++ b/ui/app/AppLayouts/Chat/popups/community/CreateChannelPopup.qml @@ -14,6 +14,7 @@ StatusModal { id: popup property bool isEdit: false + property string chatId: "" property string categoryId: "" property string channelName: "" property string channelDescription: "" @@ -22,7 +23,7 @@ StatusModal { readonly property int maxChannelDescLength: 140 signal createCommunityChannel(string chName, string chDescription, string chCategoryId) - signal editCommunityChannel(string chName, string chDescription) + signal editCommunityChannel(string chName, string chDescription, string chCategoryId) signal openPinnedMessagesPopup() //% "New channel" @@ -209,7 +210,8 @@ StatusModal { popup.categoryId) } else { popup.editCommunityChannel(Utils.filterXSS(popup.contentItem.channelName.input.text), - Utils.filterXSS(popup.contentItem.channelDescription.input.text)) + Utils.filterXSS(popup.contentItem.channelDescription.input.text), + popup.categoryId) } if (error) { diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index c1f2b4c8cf..ec11d45e23 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -227,10 +227,6 @@ ColumnLayout { }) } - onEditCommunityChannel: { - // Not Refactored Yet - } - onOpenPinnedMessagesList: { if(!chatContentModule) { console.debug("error on open pinned messages from context menu - chat content module is not set") diff --git a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml index e72a68a8ce..1e7438d67e 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContextMenuView.qml @@ -22,6 +22,8 @@ StatusPopupMenu { property string chatIcon: "" property int chatType: -1 property bool chatMuted: false + property int channelPosition: -1 + property string chatCategoryId: "" signal displayProfilePopup(string publicKey) signal displayGroupInfoPopup(string chatId) @@ -36,7 +38,7 @@ StatusPopupMenu { signal openPinnedMessagesList(string chatId) signal createCommunityChannel(string chatId, string newName, string newDescription) - signal editCommunityChannel(string chatId, string newName, string newDescription) + signal editCommunityChannel(string chatId, string newName, string newDescription, string newCategory) StatusMenuItem { id: viewProfileMenuItem @@ -124,7 +126,8 @@ StatusPopupMenu { Global.openPopup(editChannelPopup, { isEdit: true, channelName: root.chatName, - channelDescription: root.chatDescription + channelDescription: root.chatDescription, + categoryId: root.chatCategoryId }); } } @@ -138,7 +141,7 @@ StatusPopupMenu { root.createCommunityChannel(root.chatId, chName, chDescription); } onEditCommunityChannel: { - root.editCommunityChannel(root.chatId, chName, chDescription); + root.editCommunityChannel(root.chatId, chName, chDescription, chCategoryId); } onOpenPinnedMessagesPopup: { root.openPinnedMessagesList(root.chatId, chName, chDescription); diff --git a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml index ee8bc4ac76..6f808af44c 100644 --- a/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/CommunityColumnView.qml @@ -273,6 +273,8 @@ Item { chatDescription = obj.description chatType = obj.type chatMuted = obj.muted + channelPosition = obj.position + chatCategoryId = obj.categoryId } onMuteChat: { @@ -320,7 +322,13 @@ Item { } onEditCommunityChannel: { - // Not Refactored Yet + communitySectionModule.editCommunityChannel( + chatId, + newName, + newDescription, + newCategory, + channelPosition // TODO change this to the signal once it is modifiable + ) } onOpenPinnedMessagesList: {